From 0f9d2d76c4c19cea98a39ab72fbb1fbd0a10cf5f Mon Sep 17 00:00:00 2001 From: greg Date: Tue, 19 Sep 2017 03:32:15 -0700 Subject: [PATCH] Serve an actual file Convert this to stdweb soon? --- src/main.rs | 3 +++ src/webapp.rs | 10 +++++++--- static/index.html | 8 ++++++++ 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 static/index.html diff --git a/src/main.rs b/src/main.rs index cd6295d..ef1cc2f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,6 @@ #![feature(advanced_slice_patterns, slice_patterns, box_patterns)] +#![feature(plugin)] +#![plugin(rocket_codegen)] extern crate getopts; extern crate linefeed; extern crate itertools; @@ -9,6 +11,7 @@ extern crate maplit; #[macro_use] extern crate serde_derive; extern crate serde_json; +extern crate rocket; use std::path::Path; use std::fs::File; diff --git a/src/webapp.rs b/src/webapp.rs index 967d92f..e585b7c 100644 --- a/src/webapp.rs +++ b/src/webapp.rs @@ -1,8 +1,12 @@ +use rocket; + +use rocket::response::NamedFile; + #[get("/")] -fn index() -> &'static str { - "rocket test" +fn index() -> Result { + NamedFile::open("static/index.html").map_err(|_| ()) } -fn web_main() { +pub fn web_main() { rocket::ignite().mount("/", routes![index]).launch(); } diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..24c40c9 --- /dev/null +++ b/static/index.html @@ -0,0 +1,8 @@ + + + + + + Test + +