-
Notifications
You must be signed in to change notification settings - Fork 0
/
pages.js
52 lines (44 loc) · 1.33 KB
/
pages.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
42
43
44
45
46
47
48
49
50
51
52
const express = require("express");
const router = express.Router();
const fs = require("fs");
const os = require("os");
const path = require("path");
const files = __dirname + "/src/";
const path_css = files + "css/";
const path_js = files + "js/";
const path_pages = files + "pages/";
const forbiddenFilePath = path.join(path_pages, "forbidden.html");
const indexFilePath = path.join(path_pages, "index.html");
const hostFilePath = path.join(path_pages, "host.html");
router.use(express.static(files));
console.log("LOAD STATIC ITENS: " + path_css);
console.log("LOAD STATIC ITENS: " + path_js);
console.log("LOAD STATIC ITENS: " + path_pages);
router.get("/", (req, res) => {
console.log("SISTEMA <OBTER> <SITE>: " + req.url);
res.sendFile(indexFilePath);
});
router.get('/status', (req, res) => {
const healthCheck = {
uptime: process.uptime(),
message: 'OK',
timestamp: Date.now(),
cpuUsage: os.loadavg(),
memoryUsage: process.memoryUsage(),
};
try {
res.json(healthCheck);
} catch (e) {
healthCheck.message = e;
res.status(503).send();
}
});
router.get("/host", (req, res) => {
console.log("SISTEMA <OBTER> <SITE>: " + req.url);
res.sendFile(hostFilePath);
});
router.get("/debugger", (req, res) => {
console.log("SISTEMA <OBTER> <SITE>: " + req.url);
res.status(200);
});
module.exports = router;