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

概述 - Node.js API 文档

2013-09-27 11:28 585 查看
来源:http://nodejs.cn/api/synopsis/

概述#

一个简单的例子,用 Node 实现的 Web 服务器,用于响应输出 'Hello World':

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 ' target='_blank'>http://127.0.0.1:8124/');[/code] 要运行这个服务器,先将代码放入文件example.js,并使用 node 命令来执行:

> node example.js
Server running at http://127.0.0.1:8124/[/code] 文档中所有的例子均可使用相同的方式运行。
                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: