/**
* New node file
*/
var http= require('http');
var fs=require('fs');
http.createServer(function (request ,response){
if (request.method =='GET'){
//get
console.log('3');
fs.readFile('htmlpage.html',function(Error, data){
response.writeHead(200,{'Content-Type': 'text/html'});
response.end(data);
console.log('4');
});
}else if(request.method =='POST'){
//post
request.on('data', function(data){
console.log('1');
console.log('data='+data);
response.writeHead(200,{'Content-Type': 'text/html'});
response.end('<h1>'+data+'</h1>');
console.log('2');
});
}
}).listen(52775 , function(){
console.log('server running at http://127.0.0.1:52775');
});
아래 결과 post 결과값을 화면에 뿌려주었다