i want to click link to solution page,but my route don't work,what's wrong?
-
app.js
var express = require('express'); var path = require('path'); var favicon = require('serve-favicon'); var logger=require('morgan'); var cookieParser = require('cookie-parser'); var bodyParser = require('body-parser'); var expressLayouts = require('express-ejs-layouts'); var index = require('./routes/index'); var users = require('./routes/users'); var app = express(); app.set('layout', 'layout/layout'); app.set('view engine', 'ejs'); app.use(expressLayouts); app.use(logger('dev')); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); app.use(cookieParser()); app.use(express.static(path.joindirname, 'public'))); app.use('/', index); app.use('/users', users); app.use('/solution', index);
2.routes/index var express = require('express'); var router = express.Router();
router.get('/', function(req, res) { res.render('pages/index'}); }); router.get('/solution', function(req, res) { res.render('pages/solution'); }); module.exports = router;
Aucun commentaire:
Enregistrer un commentaire