diff --git a/src/main.rs b/src/main.rs index fd9fe41..8a41942 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,8 @@ extern crate rocket; +mod static_files; + #[get("/")] fn index() -> &'static str { "Hello, world!" @@ -10,6 +12,6 @@ fn index() -> &'static str { fn main() { rocket::ignite() - .mount("/", routes![index]) + .mount("/", routes![index, static_files::all]) .launch(); } diff --git a/src/static_files.rs b/src/static_files.rs new file mode 100644 index 0000000..7a546c6 --- /dev/null +++ b/src/static_files.rs @@ -0,0 +1,7 @@ +use std::path::{Path,PathBuf}; +use rocket::response::NamedFile; + +#[get("/", rank = 5)] +fn all(path: PathBuf) -> Option { + NamedFile::open(Path::new("static/").join(path)).ok() +}