-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
36 lines (28 loc) · 811 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
// app.js
// Required modules
var express = require('express');
var path = require('path');
// Create Express app
const app = express();
// Set up static file serving
app.use(express.static(path.join(__dirname, 'public')));
// Set up EJS as the view engine
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, 'views'));
// Define route for the homepage
app.get('/', (req, res) => {
res.render('index');
});
// Start the server
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
function shouldCompress (req, res) {
if (req.headers['x-no-compression']) {
// don't compress responses with this request header
return false;
}
// fallback to standard filter function
return compression.filter(req, res);
}