以下代码有什么问题?我们在app / public文件夹中包含所有.html文件。我们尝试运行以下内容,但它没有获取文件。它只是说不能得到。 非常感谢!
var finalhandler = require('finalhandler')
var http = require('http')
var serveIndex = require('serve-index')
var serveStatic = require('serve-static')
// Serve directory indexes for public/ftp folder (with icons)
var index = serveIndex('app/public/index.html', {'icons': true})
// Serve up public/ftp folder files
var serve = serveStatic('app/public/')
// Create server
var server = http.createServer(function onRequest(req, res){
var done = finalhandler(req, res)
serve(req, res, function onNext(err) {
if (err) return done(err)
index(req, res, done)
})
})
// Listen
server.listen(5000)