read file as bytes (much advance so skip step)

This commit is contained in:
AJ ONeal 2018-10-01 19:12:19 -06:00
parent f6817bcd33
commit 9bef4073a8
1 changed files with 5 additions and 2 deletions

View File

@ -20,8 +20,11 @@ fn handle_connection(mut stream: TcpStream) {
println!("Request: {}", String::from_utf8_lossy(&buffer[..]));
let response = "HTTP/1.1 200 OK\r\n\r\n";
let headers = "HTTP/1.1 200 OK\r\n\r\n".as_bytes();
stream.write(headers).unwrap();
let response = fs::read("public/index.html").unwrap();
let response = &response[..];
stream.write(response.as_bytes()).unwrap();
stream.write(response).unwrap();
stream.flush().unwrap();
}