node.js安装及小例子

1.node.js安装:http://www.nodejs.org/download/ 下载msi版本,直接双击安装,默认在c盘programfiles下,可以进行配置。

2.在某路径下建立test.js文件(本人在D:\nod目录下):

代码:

1 var http = require('http');
2 http.createServer(function (req, res) {
3     res.writeHead(200, {'Content-Type': 'text/plain'});
4     res.end('Hello World\n');
5 }).listen(1337, "127.0.0.1");
6 console.log('Server running at http://127.0.0.1:1337/');
7 console.log('SERVER RUNNING AT HTTP://127.0.0.1:1337');

 

3.进行测试:

浏览器中输入:http://127.0.0.1:1337/

文章参考来源:http://www.cnblogs.com/xcj1989/archive/2012/10/13/node_js_step_on_windows.html。感谢分享哦!

posted @ 2014-06-18 11:53  testForever  阅读(141)  评论(0编辑  收藏  举报