26 lines
851 B
Rust
26 lines
851 B
Rust
use std::fs;
|
|
|
|
use axum::{Router, response::Html, routing::get};
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
let app = Router::new()
|
|
.route("/", get(|| async { "Incorrect reverse-proxy for '/'." }))
|
|
.route("/fares", get(app_content));
|
|
let listener = tokio::net::TcpListener::bind("0.0.0.0:12000")
|
|
.await
|
|
.unwrap();
|
|
axum::serve(listener, app).await.unwrap();
|
|
}
|
|
|
|
async fn app_content() -> Html<String> {
|
|
let template = fs::read_to_string("./media/template.html")
|
|
.unwrap_or_default()
|
|
.to_string();
|
|
let mut split = template.splitn(2, "<!-- Content -->");
|
|
let mut result = split.next().unwrap().to_string();
|
|
result.push_str("Table Here!<br>(This is the position in the template the Rust code identified for the API result.)");
|
|
result.push_str(split.next().unwrap());
|
|
Html(result)
|
|
}
|