use http_server_tiny::{route, HttpServer, Method, Res}; use std::{ sync::{Arc, Mutex}, thread, }; fn main() -> Result<(), Box> { let mut server = HttpServer::new("0.0.0.0:8000", "./static/error.html"); route!(get_html => server, "/", "./static/index.html"); route!(get_html => server, "/", "./static/index.html"); route!(get_js => server, "/index.js", "./static/index.js"); let server = Arc::new(Mutex::new(server)); let mut handles = Vec::new(); for _ in 0..4 { let server = server.clone(); let handle = thread::spawn(move || { server .lock() .unwrap() .handle_requests(Box::new(|req_in| { println!("INFO: {} '{}'\n", req_in.method, req_in.url); })) .unwrap(); }); handles.push(handle); } for handle in handles { handle.join().unwrap(); } Ok(()) }