From d4ae60eed936b99b9b4fca471f97f8f647aad0c7 Mon Sep 17 00:00:00 2001 From: xomf Date: Sat, 23 Mar 2024 15:35:31 -0400 Subject: [PATCH] it brokey --- src/main.rs | 17 ++--------------- src/public/mod.rs | 13 +++++++++++++ src/public/templates.rs | 7 +++++++ 3 files changed, 22 insertions(+), 15 deletions(-) create mode 100644 src/public/mod.rs create mode 100644 src/public/templates.rs 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