就是怎么配置可以只输入域名后面不带参数,访问默认的页面。类似于asp.net的起始页。
天蓬老师2017-04-17 11:43:33
Can’t this project automatically generated by express be able to achieve such a function? !
There are a few sentences in the automatically generated project app.js
var routes = require('./routes/index');
..........
app.use('/', routes);
The content of ./routes/index.js is similar to
var express = require('express');
var router = express.Router();
router.get('/', function(req, res, next) {
//这里就是生成你默认页面的代码
//下面这句的意思是用一个叫做index的模板生成页面
res.render('index', { title: 'Chat' });
});
module.exports = router;