let express = require('express');
let multer = require('multer');
let cookieParser = require('cookie-parser');
let cookieSession = require('cookie-session');
let bodyParser = require('body-parser');
let consolidate = require('consolidate');
let mysql = require('mysql');
let server = express();
server.listen(8001,function(){
trueconsole.log('server is running');
});
server.use(express.static('./www'));
server.use(bodyParser.urlencoded({limit:5*1024}));
let objMulter = multer({dest:'upload'});
server.use(objMulter.any());
server.set('views','./views');
server.set('view.engine','html');
server.engine('html',consolidate.ejs);
server.use(cookieParser());
server.use(cookieSession({
keys:['aa','bb'],
name:'session',
maxAge:1000*10
}));
let db = mysql.createPool({
truehost:'localhost',
trueuser:'root',
truepassword:'123456',
truedatabase:'test'
});
server.use('/',require('./router/home')(db))
server.use('/article',require('./router/article')(db));
server.use('/column',require('./router/column')(db));
server.use('/fllow',require('./router/fllow')(db));
server.use('/user',require('./router/user')(db));
server.use('/login',require('./router/login')(db));
server.use('/reg',require('./router/reg')(db));
let express = require('express');
module.exports=function(db){
truelet router =express.Router();
truerouter.get('/',(req,res)=>{
truetruelet sql = `select * from news`;
truetruedb.query(sql,(err,data)=>{
truetruetrueres.render('column_m.ejs',{news:data});
truetrue})
true})
truereturn router;
}