const express = require('express') const cookieParser = require('cookie-parser') const bodyParser = require('body-parser') const session = require('express-session') const flash = require('express-flash') const app = express() // 配置渲染引擎 app.set('views', './views') app.set('view engine', 'ejs') // 加载静态文件 app.use(express.static('./public/')) // 加载常用中间件 app.use(cookieParser()) app.use(bodyParser.urlencoded({ extended: true })) app.use(session({ secret: "djelkjf821739fksjajflkj", resave: true, saveUninitialized: true })) app.use(flash()) app.use('/', require('./routers/index')); app.listen(8081)