mirror of https://github.com/rwf2/Rocket.git
24 lines
451 B
Rust
24 lines
451 B
Rust
#![feature(plugin)]
|
|
#![plugin(rocket_codegen)]
|
|
|
|
extern crate rocket;
|
|
|
|
use std::io;
|
|
use std::path::{Path, PathBuf};
|
|
|
|
use rocket::response::NamedFile;
|
|
|
|
#[get("/")]
|
|
fn index() -> io::Result<NamedFile> {
|
|
NamedFile::open("static/index.html")
|
|
}
|
|
|
|
#[get("/<file..>")]
|
|
fn files(file: PathBuf) -> Option<NamedFile> {
|
|
NamedFile::open(Path::new("static/").join(file)).ok()
|
|
}
|
|
|
|
fn main() {
|
|
rocket::ignite().mount("/", routes![index, files]).launch();
|
|
}
|