-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatic.js
41 lines (34 loc) · 1.05 KB
/
static.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
38
39
40
41
const express = require('express');
const path = require('path');
const fs = require('fs');
const router = express.Router();
router.get('/', (req, res) => {
res.render('LandingPage.html', {
process: {
env: {
HOST: process.env.HOST
}
}
});
});
router.get('/styles', (req, res) => {
res.sendFile(path.join(__dirname, '../Public/style.css'));
});
router.get('/license', (req, res) => {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET');
res.setHeader('Access-Control-Allow-Headers', 'Accept');
const filePath = path.resolve(__dirname, '../LICENSE.md');
if (!fs.existsSync(filePath)) {
console.error('License file not found at:', filePath);
return res.status(404).send('License file not found');
}
fs.readFile(filePath, 'utf8', (err, data) => {
if (err) {
console.error('Error reading license file:', err);
return res.status(500).send('Error reading license file');
}
res.type('text/plain').send(data);
});
});
module.exports = router;