我不确定如何对此进行说明,但由于缺少适当的术语,以下代码的一部分不起作用。如果我尝试转到localhost:3000/
,则不会发回回复。我正在使用Express 4.7.4和Ubuntu Trusty存储库上提供的最新节点。
app.js
///// Dependencies & config
var express = require('express');
///// Bootstrapping
//// Prepare Express
var server = express();
/// Configure Express
server.set('views', __dirname + '/views');
/// Routers
var infoR = express.Router();
// This doesn't send anything back
infoR.get("/", function(req, res) {
res.render('common/home');
});
// This works perfectly
infoR.get("/something", function(req, res) {
res.render('info/something');
});
// Routes that work
server.use('/admin', require('./routes/admin'));
server.use('/account', require('./routes/account'));
server.use('/', infoR); // This is where the problem starts
///// Start the server
server.listen(3000, function() {
console.log('Server started on port 3000');
});