|
|
@@ -1,4 +1,6 @@ |
|
|
|
use std::net::TcpListener; |
|
|
|
use std::net::{TcpStream, TcpListener}; |
|
|
|
use std::io::prelude::*; |
|
|
|
|
|
|
|
|
|
|
|
fn main() { |
|
|
|
let listener = TcpListener::bind("127.0.0.1:26382").unwrap(); |
|
|
@@ -6,6 +8,19 @@ fn main() { |
|
|
|
for stream in listener.incoming() { |
|
|
|
let stream = stream.unwrap(); |
|
|
|
|
|
|
|
println!("Connection established!"); |
|
|
|
handle_connecton(stream); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
fn handle_connecton(mut stream: TcpStream) { |
|
|
|
let mut buffer = [0; 512]; |
|
|
|
|
|
|
|
stream.read(&mut buffer).unwrap(); |
|
|
|
|
|
|
|
let response = "HTTP/1.1 200 OK\r\n\r\n"; |
|
|
|
stream.write(response.as_bytes()).unwrap(); |
|
|
|
|
|
|
|
stream.flush().unwrap(); |
|
|
|
|
|
|
|
// println!("Request: {}", String::from_utf8_lossy(&buffer[..])); |
|
|
|
} |