Started to work on server

This commit is contained in:
2018-09-24 14:32:12 +02:00
parent fb28f2bc6e
commit b7bb4f5964
5 changed files with 30 additions and 0 deletions

1
src/lib.rs Normal file
View File

@@ -0,0 +1 @@
extern crate hyper;

19
src/server.rs Normal file
View File

@@ -0,0 +1,19 @@
extern crate hyper;
use hyper::{Body, Response, Server};
use hyper::service::service_fn_ok;
use hyper::rt::{self, Future};
fn main() {
let addr = ([127, 0, 0, 1], 1500).into();
rt::run(rt::lazy(move || {
let server = Server::bind(&addr)
.serve(|| service_fn_ok(|_| Response::new(Body::from("Hello world"))))
.map_err(|e| eprintln!("server 1 error: {}", e));
rt::spawn(server);
Ok(())
}));
}