diff --git a/src/main.rs b/src/main.rs index 3f3b2cf..e3bcf13 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,27 +1,14 @@ use actix_web_lab::respond::Html; -use askama::Template; use actix_web::{web, App, HttpServer, Result, Responder}; -#[derive(Template)] -#[template(path = "index.html")] -struct IndexTemplate<'a> { - placeholder: &'a str, -} - -async fn index() -> Result { - let html = IndexTemplate { - placeholder: "hewwo world" - }.render().expect("Failed to render index.html"); - - Ok(Html(html)) -} +mod public; #[actix_web::main] async fn main() -> std::io::Result<()> { HttpServer::new(|| { App::new() - .route("/", web::get().to(index)) + .route("/", public::get().to(index)) }) .bind("0.0.0.0:8080")? diff --git a/src/public/mod.rs b/src/public/mod.rs new file mode 100644 index 0000000..f0ecaae --- /dev/null +++ b/src/public/mod.rs @@ -0,0 +1,13 @@ +use actix_web_lab::respond::Html; +use actix_web::{Result, Responder}; + +mod templates; + +async fn index() -> Result { + let html = templates::IndexTemplate { + placeholder: "hewwo world" + }.render().expect("Failed to render index.html"); + + Ok(Html(html)) +} + diff --git a/src/public/templates.rs b/src/public/templates.rs new file mode 100644 index 0000000..0234abc --- /dev/null +++ b/src/public/templates.rs @@ -0,0 +1,7 @@ +use askama::Template; + +#[derive(Template)] +#[template(path = "index.html")] +pub struct IndexTemplate<'a> { + placeholder: &'a str, +} \ No newline at end of file