2020-04-14 15:46:31 +00:00
|
|
|
const compression = require('compression');
|
|
|
|
const express = require('express');
|
|
|
|
const https = require('https');
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
const app = express();
|
|
|
|
|
2020-08-25 16:26:49 +00:00
|
|
|
const thirdTour = process.argv[2] == 3;
|
|
|
|
|
|
|
|
const publicFolderName = thirdTour ? 'public3' : 'public';
|
|
|
|
const port = thirdTour ? 8443 : 443;
|
|
|
|
|
2020-04-14 15:46:31 +00:00
|
|
|
app.use(compression());
|
2020-08-25 16:26:49 +00:00
|
|
|
app.use(express.static(publicFolderName));
|
2020-04-14 15:46:31 +00:00
|
|
|
|
|
|
|
app.get('/', (req, res) => {
|
2020-08-25 16:26:49 +00:00
|
|
|
res.sendFile(__dirname + `/${publicFolderName}/index.html`);
|
2020-04-14 15:46:31 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
https.createServer({
|
2020-06-13 08:19:39 +00:00
|
|
|
key: fs.readFileSync(__dirname + '/certs/server-key.pem'),
|
|
|
|
cert: fs.readFileSync(__dirname + '/certs/server-cert.pem')
|
2020-08-25 16:26:49 +00:00
|
|
|
}, app).listen(port, () => {
|
|
|
|
console.log('Listening port:', port, 'folder:', publicFolderName);
|
2020-04-14 15:46:31 +00:00
|
|
|
});
|