-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
43 lines (33 loc) · 1017 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
37
38
39
40
41
42
43
const express = require('express');
const app = express();
const path = require('path');
const router = express.Router();
const os = require('os');
app.set('view engine', 'ejs');
const ROOT_DIR = __dirname;
app.use(express.static(path.join(ROOT_DIR + '/public')));
router.get('/' ,(req,res) => {
showInfo(res , loadPage);
});
showInfo = (res ,next) => {
var generalInfo = new Object({
operatingSystem : os.type(),
platform : os.platform(),
hostname : os.hostname(),
freeMem : os.freemem(),
totalMem : os.totalmem(),
user : os.userInfo()
});
var data = new Object ({
generalInfo: Object.entries(generalInfo),
constants: Object.entries(os.constants) ,
cpus : Object.entries(os.cpus()),
networkInterfaces : Object.entries(os.networkInterfaces())
});
next(res,data);
}
loadPage = (res, data) => {
res.render('pages/index' , { data: data } );
}
app.use(router);
app.listen(8000);