0
我有一系列快遞是品牌的路線。 Id喜歡爲這些品牌中的每一個提供2個資產目錄。 一個public/static
適用於所有品牌的路線,然後是所有在public/brands/brandName
下。根據快遞js服務不同的資產路徑
這可能嗎?我有這樣的似乎工作,但只爲我請求的第一個/brandName
。
var express = require('express');
var app = express();
var path = require('path');
app.get('/brands/:brand', function (req, res) {
app.use(express.static(path.join(__dirname, 'public/brands/' + req.params.brand)));
res.sendFile(__dirname + '/public/static/index.html');
});
app.listen(process.env.PORT || 3000, function() {
console.log('listening on port 3000!');
});
app.use(express.static(path.join(__dirname, 'public/static')));
module.exports = app;