소스 검색

Add hello page

master
Noelle 4 년 전
부모
커밋
4b8b243310
2개의 변경된 파일13개의 추가작업 그리고 1개의 파일을 삭제
  1. 11
    0
      hello.html
  2. 2
    1
      src/main.rs

+ 11
- 0
hello.html 파일 보기

@@ -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>

+ 2
- 1
src/main.rs 파일 보기

@@ -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();

Loading…
취소
저장