建立一个简单的web server
-
导入http模块
const http = require('http');
-
创建server
const server = http.createServer((req, res) => { res.end("Hello form the server!"); });
-
开启server
server.listen(8000, "127.0.0.1", () => { console.log("Listening to requests on port 8000."); });