2016-03-22 23:27:12 +00:00
|
|
|
#![feature(plugin)]
|
2016-09-09 03:38:58 +00:00
|
|
|
#![plugin(rocket_codegen)]
|
2016-03-22 23:27:12 +00:00
|
|
|
|
|
|
|
extern crate rocket;
|
|
|
|
use rocket::Rocket;
|
2016-09-08 07:02:17 +00:00
|
|
|
|
2016-03-22 23:27:12 +00:00
|
|
|
use std::fs::File;
|
2016-03-23 00:16:17 +00:00
|
|
|
use std::io::Error as IOError;
|
2016-09-08 07:02:17 +00:00
|
|
|
use std::path::{Path, PathBuf};
|
2016-03-22 23:27:12 +00:00
|
|
|
|
2016-09-04 11:06:28 +00:00
|
|
|
#[get("/")]
|
2016-03-22 23:27:12 +00:00
|
|
|
fn index() -> File {
|
|
|
|
File::open("static/index.html").unwrap()
|
|
|
|
}
|
|
|
|
|
2016-09-08 07:02:17 +00:00
|
|
|
#[get("/<file..>")]
|
|
|
|
fn files(file: PathBuf) -> Result<File, IOError> {
|
|
|
|
File::open(Path::new("static/").join(file))
|
2016-03-22 23:27:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
Rocket::new("localhost", 8000).mount_and_launch("/", routes![index, files]);
|
|
|
|
}
|