您可以创建的另一个实例,
connect.static并在路由中使用它:
app = express.createServer()app.configure(function(){ app.use(express.static(__dirname+'/public'))})// new static middlewarevar myModuleStatic = express.static(__dirname+'/mymodule')// catch all sub-directory requestsapp.get('/mymodule/*', function(req, res){ // remove subdir from url (static serves from root) req.url = req.url.replace(/^/mymodule/, '') // call the actual middleware, catch pass-through (not found) myModuleStatic(req, res, function(){ res.send(404) })})app.listen(5555)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)