Rocket/examples/form_validation/src/files.rs

14 lines
307 B
Rust
Raw Normal View History

2016-09-12 08:51:02 +00:00
use std::path::{Path, PathBuf};
use rocket::response::NamedFile;
2016-09-12 08:51:02 +00:00
#[get("/")]
pub fn index() -> Option<NamedFile> {
NamedFile::open("static/index.html").ok()
}
#[get("/<file..>", rank = 2)]
pub fn files(file: PathBuf) -> Option<NamedFile> {
NamedFile::open(Path::new("static/").join(file)).ok()
}