-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
31 lines (26 loc) · 898 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
let express = require('express');
let path = require('path');
let bodyParser = require('body-parser');
const base = require('./modules/db.js');
let app = express();
const httpServer = require('http').createServer(app);
httpServer.listen(80, "127.0.0.1", () => { console.log("server started") });
app.set('views', path.join(__dirname, 'templates'));
app.set('view engine', 'ejs');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static(path.join(__dirname, 'static')));
app.get('/', function (req, res) {
res.render('index');
});
app.post("/min", require("./routes/min.js"));
app.get("/:id", require("./routes/all.js"));
app.use(function (req, res, next) {
let err = new Error('Not Found');
err.status = 404;
next(err);
});
app.use(function (err, req, res, next) {
res.status(err.status || 500);
res.render('error');
});