@@ -0,0 +1,11 @@ | |||
<!doctype html> | |||
<html lang="en"> | |||
<head> | |||
<meta charset="utf-8"> | |||
<title>Hello!</title> | |||
</head> | |||
<body> | |||
<h1>Hello!</h1> | |||
<p>Hi from Rust</p> | |||
</body> | |||
</html> |
@@ -17,7 +17,8 @@ fn handle_connecton(mut stream: TcpStream) { | |||
stream.read(&mut buffer).unwrap(); | |||
let response = "HTTP/1.1 200 OK\r\n\r\n"; | |||
let contents = fs::read_to_string("hello.html").unwrap(); | |||
let response = format!("HTTP/1.1 200 OK\r\n\r\n{}", contents); | |||
stream.write(response.as_bytes()).unwrap(); | |||
stream.flush().unwrap(); |