hteapot 0.6.5

HTeaPot is a lightweight HTTP server library designed to be easy to use and extend.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::{thread, time::Duration};

use hteapot::{Hteapot, HttpRequest, StreamedResponse};

fn main() {
    let server = Hteapot::new("localhost", 8081);
    server.listen(move |_req: HttpRequest| {
        let times = 5;
        StreamedResponse::new(move |sender| {
            for i in 0..times {
                let data = format!("{i}-abcd\n").into_bytes();
                let _ = sender.send(data);
                thread::sleep(Duration::from_secs(1));
            }
        })
    });
}