首先需要npm 安装'serve-static'模块.
require('http').createServer(function(req,res){
require('serve-static')('./public')(req,res,()=>{
res.end('file is not exists!');
});
}).listen(80);
首先需要npm 安装'serve-static'模块.
require('http').createServer(function(req,res){
require('serve-static')('./public')(req,res,()=>{
res.end('file is not exists!');
});
}).listen(80);
本文标题:创建简单的nodejs文件服务器
本文链接:https://www.haomeiwen.com/subject/pxzzghtx.html
网友评论