Synopsis 總述

2018-07-11 09:34 更新
使用node 實現(xiàn)的web 服務(wù)器示例,它返回'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,并使用如下命令執(zhí)行這個服務(wù)程序:

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

文檔中的其他示例,均可以類似的方式執(zhí)行。


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號