From 9b242a7a06ed128ac6fae138a7d8b28e21329c00 Mon Sep 17 00:00:00 2001 From: xomf Date: Sat, 23 Mar 2024 15:42:02 -0400 Subject: [PATCH] it worky :D --- src/main.rs | 7 +++---- src/public/mod.rs | 4 +++- src/public/templates.rs | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) 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