use rocket::fs::NamedFile; use rocket::response::status::NotFound; use std::path::{Path, PathBuf}; #[get("/static/")] pub async fn static_files(file: PathBuf) -> Result> { NamedFile::open(Path::new("static/").join(file)) .await .map_err(|e| NotFound(e.to_string())) }