-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
37 lines (32 loc) · 891 Bytes
/
app.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
const express = require("express");
const app = express();
const bodyParser = require("body-parser");
const session = require("express-session");
const flash = require("connect-flash");
const port = process.env.PORT || 3000;
const results = require("./routes/result.js");
app.use(express.static("public"));
app.use(bodyParser.urlencoded({ extended: true }));
app.set("view engine", "ejs");
app.use(
session({
secret: "Secret",
resave: false,
saveUninitialized: false,
maxAge: 1000 * 60 * 10, // 10 Minutes
})
);
app.use(flash());
app.use((req, res, next) => {
res.locals.error = req.flash("error");
res.locals.success = req.flash("success");
next();
});
/* Result Route */
app.use(results);
/* Server */
let http = require("http");
let server = express().use("/", app);
http.createServer(server).listen(port, () => {
console.log("Listening on " + port);
});