Serve an actual file

Convert this to stdweb soon?
This commit is contained in:
greg 2017-09-19 03:32:15 -07:00
parent 006fd7d411
commit 0f9d2d76c4
3 changed files with 18 additions and 3 deletions

View File

@ -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;

View File

@ -1,8 +1,12 @@
use rocket;
use rocket::response::NamedFile;
#[get("/")]
fn index() -> &'static str {
"rocket test"
fn index() -> Result<NamedFile, ()> {
NamedFile::open("static/index.html").map_err(|_| ())
}
fn web_main() {
pub fn web_main() {
rocket::ignite().mount("/", routes![index]).launch();
}

8
static/index.html Normal file
View File

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body>
Test
</body>
</html>