node.js http (1) 썸네일형 리스트형 6-1 http 모듈을 이용한 간단한 웹서버 1. http 모듈을 이용하여 index.html 을 로드후 브라우저에 뿌려주는 간단한 서버 프로그램 입니다. index.html을 로드 하기 위해 fs 모듈을 이용합니다. (fs 모듈은 참고하시기 바랍니다.) server.js 소스 var fs = require("fs"); var http = require("http"); http.createServer(function(req, res) { fs.readFile('index.html', function(err, data){ res.writeHead(200, {'Content-Type':'text/html'}); res.end(data); }); }).listen(8080, function(){ console.log("server running"); }.. 이전 1 다음