diff --git a/src/main.rs b/src/main.rs index e3bcf13..b283567 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,4 @@ -use actix_web_lab::respond::Html; -use actix_web::{web, App, HttpServer, Result, Responder}; +use actix_web::{web, App, HttpServer}; mod public; @@ -8,10 +7,10 @@ async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() - .route("/", public::get().to(index)) + .route("/", web::get().to(public::index)) }) .bind("0.0.0.0:8080")? .run() .await -} +} \ No newline at end of file diff --git a/src/public/mod.rs b/src/public/mod.rs index f0ecaae..0116f8e 100644 --- a/src/public/mod.rs +++ b/src/public/mod.rs @@ -1,9 +1,11 @@ use actix_web_lab::respond::Html; use actix_web::{Result, Responder}; +use askama::Template; + mod templates; -async fn index() -> Result { +pub async fn index() -> Result { let html = templates::IndexTemplate { placeholder: "hewwo world" }.render().expect("Failed to render index.html"); diff --git a/src/public/templates.rs b/src/public/templates.rs index 0234abc..b0c306a 100644 --- a/src/public/templates.rs +++ b/src/public/templates.rs @@ -3,5 +3,5 @@ use askama::Template; #[derive(Template)] #[template(path = "index.html")] pub struct IndexTemplate<'a> { - placeholder: &'a str, + pub placeholder: &'a str, } \ No newline at end of file