Rocket/examples/form_validation/src/files.rs

15 lines
318 B
Rust
Raw Normal View History

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