it worky :D

This commit is contained in:
xomf 2024-03-23 15:42:02 -04:00
parent d4ae60eed9
commit 9b242a7a06
3 changed files with 7 additions and 6 deletions

View File

@ -1,5 +1,4 @@
use actix_web_lab::respond::Html; use actix_web::{web, App, HttpServer};
use actix_web::{web, App, HttpServer, Result, Responder};
mod public; mod public;
@ -8,10 +7,10 @@ async fn main() -> std::io::Result<()> {
HttpServer::new(|| { HttpServer::new(|| {
App::new() App::new()
.route("/", public::get().to(index)) .route("/", web::get().to(public::index))
}) })
.bind("0.0.0.0:8080")? .bind("0.0.0.0:8080")?
.run() .run()
.await .await
} }

View File

@ -1,9 +1,11 @@
use actix_web_lab::respond::Html; use actix_web_lab::respond::Html;
use actix_web::{Result, Responder}; use actix_web::{Result, Responder};
use askama::Template;
mod templates; mod templates;
async fn index() -> Result<impl Responder> { pub async fn index() -> Result<impl Responder> {
let html = templates::IndexTemplate { let html = templates::IndexTemplate {
placeholder: "hewwo world" placeholder: "hewwo world"
}.render().expect("Failed to render index.html"); }.render().expect("Failed to render index.html");

View File

@ -3,5 +3,5 @@ use askama::Template;
#[derive(Template)] #[derive(Template)]
#[template(path = "index.html")] #[template(path = "index.html")]
pub struct IndexTemplate<'a> { pub struct IndexTemplate<'a> {
placeholder: &'a str, pub placeholder: &'a str,
} }