qingzhu1224

导航

nodeJs中创建服务器

var http=require('http');

var httpObj=http.createServer(function(req,res) {
console.log('someBody:' + req.url);
switch (req.url) {
case '/a.html':
res.write('AA');
res.end();
break;
case '/b.html':
res.write('B');
res.end();
break;
default :
res.write('Index');
res.end();
break;
}
});

httpObj.listen(8081);

posted on 2015-12-17 12:50  qingzhu1224  阅读(200)  评论(0编辑  收藏  举报