File size: 873 Bytes
6b393b4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
const express = require('express');
const router = express.Router();
const os = require('os');
const fs = require('fs');
const path = require('path');

router.get('/count', (req, res) => {
  try {
    res.json({
      visitor_count: visitorCount,
      visitor_today: visitorToday
    });
  } catch (error) {
    console.error(error);
    res.status(500).json({ error: 'Internal Server Error' });
  }
});

router.get('/status', (req, res) => {
  try {
    const uptime = os.uptime();
    const runtime = formatUptime(uptime);
    const memory = {
      free: formatBytes(os.freemem()),
      total: formatBytes(os.totalmem())
    };

    res.json({
      runtime: runtime,
      memory: `${memory.free} / ${memory.total}`
    });
  } catch (error) {
    console.error(error);
    res.status(500).json({ error: 'Internal Server Error' });
  }
});


module.exports = router;