it brokey

This commit is contained in:
xomf 2024-03-23 15:35:31 -04:00
parent e90350b1f7
commit d4ae60eed9
3 changed files with 22 additions and 15 deletions

View File

@ -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<impl Responder> {
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")?

13
src/public/mod.rs Normal file
View File

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

7
src/public/templates.rs Normal file
View File

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