Spaces:
Paused
Paused
| 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; | |