Rocket/examples/hello/src/main.rs

22 lines
463 B
Rust
Raw Normal View History

#![feature(plugin)]
#![plugin(rocket_macros)]
extern crate rocket;
use rocket::Rocket;
use std::fs::File;
#[route(GET, path = "/")]
fn root() -> File {
File::open("/tmp/index.html").unwrap()
}
#[route(GET, path = "/hello/<name>/<age>")]
fn hello(name: &str, age: i8) -> String {
2016-03-18 03:37:34 +00:00
format!("Hello, {} year old named {}!", age, name)
}
fn main() {
let rocket = Rocket::new("localhost", 8000);
rocket.mount_and_launch("/", routes![root, hello]);
}