From 1f1eea31a09734371dc3f98fe7e42b65734f07d6 Mon Sep 17 00:00:00 2001 From: Florian Briand Date: Wed, 3 Jul 2024 17:50:29 +0200 Subject: [PATCH] chore: Add htmx on an index.html root page --- src/main.rs | 27 ++++++++++++++++++--------- templates/index.html | 12 ++++++++++++ 2 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 templates/index.html diff --git a/src/main.rs b/src/main.rs index 872e94e..e2187bf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,21 +4,30 @@ use axum::{ }; use askama_axum::Template; +#[tokio::main] +async fn main() { + let app = Router::new() + .route("/", get(index)) + .route("/hello", get(hello_world)); + + let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap(); + axum::serve(listener, app).await.unwrap(); +} + +#[derive(Template)] +#[template(path = "index.html")] +struct IndexTemplate {} + +async fn index() -> IndexTemplate { + IndexTemplate {} +} + #[derive(Template)] #[template(path = "hello.html")] struct HelloTemplate<'a> { name: &'a str, } -#[tokio::main] -async fn main() { - let app = Router::new() - .route("/", get(hello_world)); - - let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap(); - axum::serve(listener, app).await.unwrap(); -} - async fn hello_world() -> HelloTemplate<'static> { HelloTemplate { name: "world" } } diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..42d8c7c --- /dev/null +++ b/templates/index.html @@ -0,0 +1,12 @@ + + + Krys4lide + + + + +

Krys4lide

+ +
+ + \ No newline at end of file