node.js的路由
app.js:
app.use('/', routes);
app.use('/reg', routes);
app.use('/u/:user',routes);
app.use('/post',routes);
app.use('doReg',routes);
app.use('login',routes);
app.use('login',routes);
app.use('logout',routes);
app.use('/users', users);
routes/index.js
var express = require('express');
var router = express.Router();
/* GET home page. */
router.get('/', function(req, res, next) {
res.render('index', { title: '首页' });
});
router.get('/u/:user', function(req, res, next) {
});
router.post('/post', function(req, res, next) {
res.render('post', { title: 'post' });
});
router.get('/reg', function(req, res, next) {
res.render('reg', { title: '注册页面' });
});
router.post('/doReg', function(req, res, next) {
res.render('doreg', { title: 'doreg' });
});
router.get('/login', function(req, res, next) {
res.render('login', { title: '登录页面' });
});
router.post('/doLogin', function(req, res, next) {
res.render('dologin', { title: 'doLogin' });
});
router.get('/logout', function(req, res, next) {
res.render('logout', { title: 'logout' });
});
module.exports = router;