Rocket/examples/todo/src/static_files.rs

8 lines
201 B
Rust

use std::path::{Path, PathBuf};
use rocket::response::NamedFile;
#[get("/<path..>", rank = 5)]
fn all(path: PathBuf) -> Option<NamedFile> {
NamedFile::open(Path::new("static/").join(path)).ok()
}