use actix_web::{get, HttpRequest, Responder}; use maud::html; #[get("/redBG")] pub async fn red_bg(r: HttpRequest) -> impl Responder { let content = html! { p { "Red" }; } .into_string(); // build site with custom configuration web_base::build_site_opt( // get the base site configuration from request &web_base::Site::from_request(&r) // apply custom configuration .head_content( html! { style { "body { background-color: red; }" } } .into_string(), ), "Red", &content, ) } #[get("/")] pub(crate) async fn index(r: HttpRequest) -> impl Responder { let content = html!( p { "Hello World" }; a href="/redBG" { "click" }; ) .into_string(); // build site web_base::build_site(&r, "Index", &content) } #[actix_web::main] async fn main() -> std::io::Result<()> { web_base::map!( web_base::Site::new() .enable_bootstrap(false) .enable_picocss(false), |app: actix_web::App<_>| { app.service(index).service(red_bg) } ) .bind(("0.0.0.0".to_string(), 8080))? .run() .await }