var express=require('express');
var static=require('express-static');
var mysql=require('mysql');
var bodyParser=require('body-parser');
var multer=require('multer');
var cookieParser=require('cookie-parser');
var cookieSession=require('cookie-session');
var consolidate=require('consolidate');
var expressRoute=require('express-route');
var multerObj=multer({dest:'./upload'});
var ejs=require('ejs');
var server=express();
server.listen(8080);
//获取前台请求数据
//get自带 req.query
//post
server.use(multerObj.any());
//cookie
server.use(cookieParser());
//session
(function(){
var keys=[];
for(var i=0;i<10000;i++){
keys[i]='keys_id'+Math.random();
}
server.use(cookieSession({
name:'session_id',
keys:keys,
maxAge:20*60*1000 //20min
}))
})();
//模板
server.engine('html',consolidate.ejs);
server.set('views','template');
server.set('view engine','html');
//route
//var createRouter=require('./route/1.js');
server.use('/article/',require('./route/1.js')());
var r2=express.Router();
server.use('/blog/',r2);
//获取前台静态数据
server.use(static('./static/'));