| <!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> |
| stream.read(&mut buffer).unwrap(); | 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.write(response.as_bytes()).unwrap(); | ||||
| stream.flush().unwrap(); | stream.flush().unwrap(); |