1.server.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | // 모듈 추가 var fs = require( 'fs' ); var http = require( 'http' ); // 서버 실행 http.createServer( function (request, response){ //html 파일 읽기 fs.readFile( 'index.html' , function (error, data){ response.writeHead(200, { 'Content-Type' : 'text/html' }); response.end(data); }); }).listen(3000, function (){ }); |
2. index.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> < HTML > < HEAD > < TITLE >http and FileSystem</ TITLE > < META NAME = "Generator" CONTENT = "EditPlus" > < META NAME = "Author" CONTENT = "" > < META NAME = "Keywords" CONTENT = "" > < META NAME = "Description" CONTENT = "" > </ HEAD > < BODY > < h1 >Hello Node.js</ h1 > </ BODY > </ HTML > |
'프로그래밍 > nodeJS' 카테고리의 다른 글
[nodeJS] jade 모듈 (0) | 2015.01.27 |
---|---|
[nodeJS] ejs 모듈 (0) | 2015.01.27 |
[nodeJS] hello world (0) | 2014.12.29 |
[nodeJS] nodeJS 란? (0) | 2014.12.29 |
[nodeJS] nodeJS 설치하기(윈도우용-ver 0.10.34 기준) (0) | 2014.12.28 |