-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
30 lines (24 loc) · 667 Bytes
/
app.js
File metadata and controls
30 lines (24 loc) · 667 Bytes
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
const http = require('http');
const express = require('express');
const router = require('./routes/endpoints');
const HTTP_PORT = process.env.PORT || 8000;
var options = {
maxAge: '7d',
redirect: false
}
var app = express();
app.use(express.static('public', options));
app.use('/', router);
app.set('view engine', 'ejs');
app.disable('x-powered-by');
http.createServer(app).listen(HTTP_PORT, () => {
console.log(`Server is running on port ${HTTP_PORT}`);
});
app.use(function(req, res, next) {
res.status(404);
// respond with html page
if (req.accepts('html')) {
res.render('errors/404', { url: req.url });
return;
}
});