Serve an actual file
Convert this to stdweb soon?
This commit is contained in:
parent
006fd7d411
commit
0f9d2d76c4
@ -1,4 +1,6 @@
|
|||||||
#![feature(advanced_slice_patterns, slice_patterns, box_patterns)]
|
#![feature(advanced_slice_patterns, slice_patterns, box_patterns)]
|
||||||
|
#![feature(plugin)]
|
||||||
|
#![plugin(rocket_codegen)]
|
||||||
extern crate getopts;
|
extern crate getopts;
|
||||||
extern crate linefeed;
|
extern crate linefeed;
|
||||||
extern crate itertools;
|
extern crate itertools;
|
||||||
@ -9,6 +11,7 @@ extern crate maplit;
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate serde_derive;
|
extern crate serde_derive;
|
||||||
extern crate serde_json;
|
extern crate serde_json;
|
||||||
|
extern crate rocket;
|
||||||
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
|
use rocket;
|
||||||
|
|
||||||
|
use rocket::response::NamedFile;
|
||||||
|
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
fn index() -> &'static str {
|
fn index() -> Result<NamedFile, ()> {
|
||||||
"rocket test"
|
NamedFile::open("static/index.html").map_err(|_| ())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn web_main() {
|
pub fn web_main() {
|
||||||
rocket::ignite().mount("/", routes![index]).launch();
|
rocket::ignite().mount("/", routes![index]).launch();
|
||||||
}
|
}
|
||||||
|
8
static/index.html
Normal file
8
static/index.html
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
Test
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user