Use askama to render test template

This commit is contained in:
Joscha 2023-08-03 18:35:09 +02:00
parent 3f5ad25f9e
commit 8b5bfdd231
7 changed files with 152 additions and 2 deletions

View file

@ -1,10 +1,24 @@
mod r#static;
use askama::Template;
use axum::{routing::get, Router};
#[derive(Template)]
#[template(path = "index.html")]
struct IndexTemplate {
greetee: String,
}
async fn run() -> anyhow::Result<()> {
let app = Router::new()
.route("/", get(|| async { "Hello, world!" }))
.route(
"/",
get(|| async {
IndexTemplate {
greetee: "world".to_string(),
}
}),
)
.fallback(get(r#static::static_handler));
axum::Server::bind(&"0.0.0.0:8000".parse().unwrap())