NodeJS
NodeJS入门 NodeJS模块 http模块 server.js const http=require('http'); let server=http.createServer((req, res)=>{ switch(req.url){ case '/aaa': res.write('abc'); break; case '/bbb': res.write('dddd'); break; case '/1.html': res.write('<html><head></head><body>sdfasfasf</body></html>'); break; } res.end(); }); server.listen(8080); server2.js const http=require('http'); const fs=require('fs'); let server=http.createServer((req, res)=>{ fs.readFile(`www${req.url}`, (err, data)=>{ if(err){ res.write('404'); //? }else{ res.write(data); } res.end(); }); }); server.listen(8080); 断言——assert const assert