좋은 프로그램은 마음의 여유에서 나온다.

node.js로 웹서버 만들기 본문

프로그래밍/node.js

node.js로 웹서버 만들기

좋은데이 2012. 8. 30. 11:54

sudo vim node.server.js


var http = require('http');


http.createServer(function (request, response) {

response.writeHead(200, { 'Content-Type': 'text/html' });

response.end('<h1>Hello World</h1>');

}).listen(80, function () {

console.log('Running Server');

});


vim을 빠져 나와서 

node node.server.js

를 실행하면 Running Server 이라는 문구가 나옴

웹브라우저를 열고 http://127.0.0.1로 들어가면 Hello World가 나올 것임

'프로그래밍 > node.js' 카테고리의 다른 글

node.js + express + i18n + ejs로 다국어 지원  (0) 2013.08.23
http 서버 응답 코드  (0) 2013.08.09
파일에 로그 남기기  (0) 2012.09.11
node.js에 scribe 모듈 설치  (0) 2012.08.31
node.js 설치  (0) 2012.08.30
Comments