首先利用到的知识有:http模块、url模块、fs模块;
let http = require("http"); let url = require("url"); let fs=require("fs"); http.createServer((Request, Response) => { console.log(__dirname+result); fs.readFile(__dirname+result,(err,data)=>{ Response.write(data); Response.end(); }) }).listen("8080", () => { console.log("监听成功 8080"); //用于判断端口是否开启 })