You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We only have the log crate because we want to print out that the server is starting; we only print out the server is starting because there's no way to customize this kind of thing. The Node api we're emulating does, however.
It might look something like this:
#[macro_use]externcrate log;externcrate env_logger;externcrate simple_server;use simple_server::Server;fnmain(){
env_logger::init().unwrap();let host = "127.0.0.1";let port = "7878";let server = Server::new(|request,mut response| {info!("Request received. {} {}", request.method(), request.uri());Ok(response.body("Hello Rust!".as_bytes())?)});
server.listen(host, port, || {info!("Server started on {}:{}", host, port);});}
Thoughts?
The text was updated successfully, but these errors were encountered:
We only have the
log
crate because we want to print out that the server is starting; we only print out the server is starting because there's no way to customize this kind of thing. The Node api we're emulating does, however.It might look something like this:
Thoughts?
The text was updated successfully, but these errors were encountered: