核心代碼 app.js
//app.js 文件名
var routes = require('./routes/index');
app.use('/index', routes);
//index.js 文件名
var express = require('express');
var router = express.Router();
router.get('/', function(req, res, next) {
res.render('index', { title: 'Express' });
});
router.get('/about', function(req, res, next) {
res.json({ user: 'aaa' });
});
module.exports = router;