>npm install jade
1. server.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | //모듈 추출 var http = require( 'http' ); var jade = require( 'jade' ); var fs = require( 'fs' ); //서버를 생성하고 실행 http.createServer( function (request, response){ //jade 파일 읽기 fs.readFile( 'index.jade' , 'utf8' , function (error, data){ // jade 모듈 사용 var fn = jade.compile(data); // 출력 response.writeHead(200, { 'Content-Type' : 'text/html' }); response.end(fn()); }); }).listen(3000, function (){ console.log( 'Server Running at http:127.0.0.1:3000' ); }); |
2. index.jade
1 2 3 4 5 6 7 8 | html head title Jade Example body h1 Hello Jade p Node.js & Jade hr |
'프로그래밍 > nodeJS' 카테고리의 다른 글
[nodeJS] Express / Routes / Jade 모듈 (0) | 2015.01.27 |
---|---|
[nodeJS] connect / connect_router 모듈 (0) | 2015.01.27 |
[nodeJS] ejs 모듈 (0) | 2015.01.27 |
[nodeJS] http 모듈 + FileSystem 모듈 (0) | 2014.12.29 |
[nodeJS] hello world (0) | 2014.12.29 |