2016-03-22 23:27:12 +00:00
|
|
|
#![feature(plugin)]
|
|
|
|
#![plugin(rocket_macros)]
|
|
|
|
|
|
|
|
extern crate rocket;
|
|
|
|
|
|
|
|
use rocket::Rocket;
|
|
|
|
use std::fs::File;
|
2016-03-23 00:16:17 +00:00
|
|
|
use std::io::Error as IOError;
|
2016-03-22 23:27:12 +00:00
|
|
|
|
|
|
|
#[route(GET, path = "/")]
|
|
|
|
fn index() -> File {
|
|
|
|
File::open("static/index.html").unwrap()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[route(GET, path = "/<file>")]
|
2016-03-23 00:16:17 +00:00
|
|
|
fn files(file: &str) -> Result<File, IOError> {
|
|
|
|
File::open(format!("static/{}", file))
|
2016-03-22 23:27:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
Rocket::new("localhost", 8000).mount_and_launch("/", routes![index, files]);
|
|
|
|
}
|