您的位置:首页 > Web前端 > Node.js

nodeJS入门例子一概要(Synopsis)

2011-11-21 15:35 267 查看
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/[/code] [/code]
                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: