-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.rs
More file actions
26 lines (24 loc) · 670 Bytes
/
Copy pathmain.rs
File metadata and controls
26 lines (24 loc) · 670 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use std::net::TcpListener;
use std::process;
use httpserver::{parsers, ThreadPool};
fn main() {
let url = "127.0.0.1:7878";
let listener = TcpListener::bind(url).unwrap_or_else(|e| {
eprintln!("Error: {e}", e = e);
process::exit(1);
});
let pool = match ThreadPool::new(5) {
Ok(p) => p,
Err(e) => {
eprintln!("{}", e);
process::exit(1);
}
};
println!("Serving your application at http://{}", url);
for stream in listener.incoming() {
let mut stream = stream.unwrap();
pool.execute(move || {
parsers::handle_client(&mut stream);
});
}
}