i did some stuff

This commit is contained in:
2026-01-19 20:46:54 +00:00
parent 2f2d3073d8
commit d52c29d583
6 changed files with 107 additions and 57 deletions

View File

@@ -16,8 +16,13 @@ use smol::{fs, io, prelude::*, Async, Executor};
use smol_hyper::rt::{FuturesIo, SmolTimer};
use smol_macros::main;
mod assets;
mod loader;
mod page;
use crate::assets::AssetStore;
use crate::loader::*;
use crate::page::*;
struct AppState<'a> {
pub pages: Vec<Page>,
@@ -41,14 +46,21 @@ async fn serve(req: Request<Incoming>, state: Arc<AppState<'_>>) -> Result<Respo
false
}
});
let reply = match mreow {
let reply: Bytes = match mreow {
Some(x) => state
.env
.get_template(&x.header.id)
.unwrap()
.render(context! {})
.unwrap(),
None => "?".to_string(),
.unwrap()
.into(),
None => match AssetStore::new("./templateServe/_assets/".into())
.load_asset(path)
.await
{
Ok(asset) => asset,
Err(_) => "".into(),
},
};
Ok(Response::new(Full::new(reply.into())))
}