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,并使用如下命令執(zhí)行這個(gè)服務(wù)程序:
> node example.js
Server running at http://127.0.0.1:8124/
文檔中的其他示例,均可以類(lèi)似的方式執(zhí)行。
更多建議: