read file as bytes (much advance so skip step)
This commit is contained in:
parent
f6817bcd33
commit
9bef4073a8
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue