tide 0.10.0

Serve the web – HTTP server framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use async_std::task;
use tide::{Body, Response, StatusCode};

fn main() -> Result<(), std::io::Error> {
    task::block_on(async {
        let mut app = tide::new();
        app.at("/").get(|_| async move {
            let mut res = Response::new(StatusCode::Ok);
            res.set_body(Body::from_file(file!()).await.unwrap());
            Ok(res)
        });
        app.listen("127.0.0.1:8080").await?;
        Ok(())
    })
}