다음과 같은 코드가 있다.
| 
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 | 
//http모듈을 추출 
var http = require('http'); 
//52273번 포트에 서버를 생성하고 실행 
http.createServer(function(request, response){ 
response.writeHead(404); 
response.end(); 
}).listen(52273,function(){ 
console.log('Server Running at http://127.0.0.1:52273'); 
}); | cs | 
response.writeHead()에서 첫번째 매개변수를 status Code라고 한다.
404를 매개변수로 보내주면, 웹페이지를 띄우수 없다는 경고 문구가 뜨게 된다.
댓글
댓글 쓰기