Node.JS创建服务

一、源码

var http=require('http');
http.createServer(function(req,res){
res.writeHead(200,{'Content-Type':'text/html'});
res.write('<h1>我们的服务123</h1>');
res.end('<p>fffffff</p>');
}).listen(5858);

 

记事本书写源码,UTF-8格式保存为js格式,cmd找到对应的文件路径,node 服务名.js,然后在浏览器中访问:localhost:5858  即可。

posted @ 2016-05-03 22:20  飙速  阅读(176)  评论(0编辑  收藏  举报