中国最全IT社区平台 联系我们 | 收藏本站
华晨云阿里云优惠2

nodejs教程

Node.js 概述

阅读 (2288)

概述

第一个 服务器 的例子就从 “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 http://127.0.0.1:8124/');

把代码拷贝到example.js文件里,用 node 程序执行

> node example.js
Server running at http://127.0.0.1:8124/

文档中所有的例子都可以这么执行。

关闭
程序员人生