diff --git a/Cargo.toml b/Cargo.toml index 93fac06..70fde55 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,4 +7,6 @@ edition = "2021" [dependencies] tokio = { version = "1", features = ["rt-multi-thread"]} -axum = "0.7" \ No newline at end of file +axum = "0.7" +askama = "0.12" +askama_axum = "0.4" diff --git a/src/main.rs b/src/main.rs index ee84d16..3d5f385 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +use askama::Template; use axum::{routing::get, Router}; #[tokio::main] @@ -9,6 +10,12 @@ async fn main() -> Result<(), Box> { Ok(()) } -async fn root() -> &'static str { - "It works!" +#[derive(Template)] +#[template(path = "index.html")] +struct IndexTemplate<'a> { + title: &'a str, +} + +async fn root<'a>() -> IndexTemplate<'a> { + IndexTemplate { title: "LocalHub" } } diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..d925a10 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,11 @@ + + + + + + {{title}} + + + It still works! + +