精选圈子榜单优站
编程综合
编程综合
技术
20关注
编程技术记录、分享 ,记录你的编程生活点点滴滴!

[NodeJS]第一个服务器端程序


$ vim firstServer.js

输入:

var http = require('http');
http.createServer(function (request,response){
        response.writeHead(200,{'Content-Type':'text/plain'});
        response.end('Hello world\n');
}).listen(8888);

console.log('Server is running at http://localhost:8888/');


wq保存。

$ node firstNode.js 
Server is running at http://localhost:8888/

此时服务已经启动。

打开浏览器访问:

http://localhost:8888







  • 若文章侵犯了您的权益,请联系我们进行处理。

  • 2016-06-13
  • 4156阅读
评论