Something went wrong. Try again.
Just the source code for my personal website.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263use std::path::Path;
use rocket::{ State, fairing::AdHoc, fs::{FileServer, NamedFile}, get, launch, routes, serde::{Deserialize, Serialize},};use rocket_dyn_templates::{Template, context};
#[derive(Debug, Deserialize, Serialize)]#[serde(crate = "rocket::serde")]struct Config { pub public_url: String,}
#[get("/")]fn index(config: &State<Config>) -> Template { Template::render( "index", context! { url: config.public_url.clone(), }, )}
#[get("/dms")]fn dms(config: &State<Config>) -> Template { Template::render( "dms", context! { url: config.public_url.clone(), }, )}
#[get("/carrd")]fn carrd(config: &State<Config>) -> Template { Template::render( "carrd", context! { url: config.public_url.clone(), }, )}
#[get("/favicon.ico")]async fn icon() -> Option<NamedFile> { NamedFile::open(Path::new("./static/favicon.ico")) .await .ok()}
#[launch]fn rocket() -> _ { rocket::build() .mount("/", routes![index, dms, carrd, icon]) .mount("/assets", FileServer::from("./static")) .attach(Template::fairing()) .attach(AdHoc::config::<Config>())}