Hello world 入門示例
新建server.js誉碴,并編寫代碼:
var http = require('http');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
}).listen(8023);
console.log('Server running at http://127.0.0.1:8023/');
運行server.js文件厦幅,開啟服務:
$~ node server.js
$~ Server running at http://127.0.0.1:8023/
最后打開任意瀏覽器打開這個地址:http://127.0.0.1:8023/ 蜘澜,就可以看到Hello World
字樣.