-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
40 lines (33 loc) · 848 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const express = require('express');
const path = require('path');
const port = 8000;
const app = express();
const session = require('express-session');
const flash = require('connect-flash');
const db = require('./config/mongoose');
app.use(session({
secret: 'DTUFTE',
saveUninitialized: true,
resave: true
}));
app.use(flash());
app.use(function (req, res, next) {
res.locals.flash = {
'success': req.flash('success'),
'error': req.flash('error')
}
next();
});
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, 'views'));
app.use(express.urlencoded());
app.use('/', require('./routes'));
app.use(express.static(path.join(__dirname, 'assests')));
app.listen(port, function (err) {
if (err) {
console.log('Error in opening server');
return;
}
console.log('server is serving');
return;
})