一、環境
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 並顯示。