`
yangzhiyong77
  • 浏览: 965907 次
文章分类
社区版块
存档分类
最新评论

nodeJS入门例子一概要(Synopsis)

 
阅读更多

node 版本0.6.2

OS:ubuntu 10.04


一个使用Node写的只有"Hello World"返回的web 服务器

var http = require('http');

http.createServer(function (request, response) {
  response.writeHead(200, {'Content-Type': 'text/plain'});
  response.end('Hello World\n');
}).listen(8124);

console.log('Server running at http://127.0.0.1:8124/');
将上述代码保存到example.js中,并在控制台执行如下命令
> node example.js
控制台将打印日志
Server running at http://127.0.0.1:8124/



分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics