一、环境
Node.js版本:v12.13.0
vscode版本:1.39.2
二、建立环境
const http = require('http');
const createHttp = http.createServer((req, res) => {
res.end('ok');
);
createHttp.listen('80', '127.0.0.1', () => {
console.log('http://127.0.0.1:80 is running.');
});
此时在浏览器输入 127.0.0.1:80 会返回 ok 并显示。