media-collection-crud/src/main.rs

42 lines
677 B
Rust

#[macro_use]
extern crate mime;
use iron::prelude::*;
use iron::status;
use router::Router;
mod db;
fn init_router() -> Router {
let mut router = Router::new();
router.get("/", |_request: &mut Request| {
let mut response = Response::new();
response.set_mut(status::Ok);
response.set_mut(mime!(Text/Html; Charset=Utf8));
response.set_mut(r#"
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Rust web server</title>
</head>
<body>
<h1>Hello, world!</h1>
</body>
</html>
"#);
Ok(response)
}, "root");
router
}
fn main() {
let router = init_router();
Iron::new(router)
.http("localhost:8000")
.unwrap();
}