use std::path::Path; use config::Config; use rocket::fs::NamedFile; use rocket::response::content::RawHtml; use rocket::{get, launch, routes, State}; mod config; mod site; #[get("/static/")] async fn icon_res(file: &str) -> Option { let path = Path::new("static").join(file); NamedFile::open(path).await.ok() } #[get("/")] pub fn main_page(c: &State) -> RawHtml { RawHtml(site::gen_site(c)) } // todo : fav icon #[launch] async fn rocket() -> _ { let conf_path: String = std::env::args() .skip(1) .next() .unwrap_or("./config.yml".to_string()); let conf = config::Config::load(&conf_path); rocket::build() .mount("/", routes![main_page, icon_res]) .manage(conf) }