http_server_tiny 0.1.6

HTTP SERVER
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use http_server_tiny::{HttpServer, Method, Res};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut server = HttpServer::new("0.0.0.0:8000", "./static/error.html");
    server.add_route(
        &Method::Get,
        "/",
        Box::new(|_| Res::File {
            name: "./static/index.html",
            ct: "text/html; charset=utf-8",
            sc: 200,
        }),
    );

    server.handle_requests(Box::new(|req| {
        println!("INFO: {} {}", req.method, req.url);
    }))
}