createServer();function createServer(){var http = nodeRe优艾设计网_PS百科quire("http"); http.createServer(function(request, response) {let path = request.url; response.writeHead(200, {"Content-Type": "text/html"}); let fs = nodeRequire("fs"); let data = fs.readFileSync(app_dir+path); response.write(data.toString()); response.end();}).listen(8888);}
就像这样,输出一个html文件,跟正常访问一样,不过遇到css、js什么都要自己判断。应该有现成的轮子可用了,推荐一个吧?
生活真心操蛋 2022-06-09 06:20 优艾设计网_PS交流
express
精彩评论