一、建立一个http web服务器,并返回Hello World!node
const http = require('http'); http.createServer( (request, response) => { response.writeHead(200, {'Content-Type': 'text/plain'}); response.end('Hello World\n'); }).listen(8888); console.log('Server running at http://127.0.0.1:8888/');
二、启动服务器,在浏览器中输入http://127.0.0.1:8888/,页面显示Hello World。web
$ node example.js Server running at http://127.0.0.1:8888/