const express = require('express'); const app = express(); const port = process.env.PORT || 7860; const requestIp = require('request-ip'); app.use(express.static('public')); // Create a route that returns the HTML with Beijing time and IP app.get('/', (req, res) => { const clientIp = requestIp.getClientIp(req) || "Unknown"; // Get current time in Beijing (UTC+8) const now = new Date(); const beijingTime = new Date(now.getTime() + (8 * 60 * 60 * 1000)); const hours = beijingTime.getUTCHours().toString().padStart(2, '0'); const minutes = beijingTime.getUTCMinutes().toString().padStart(2, '0'); const timeString = `${hours}:${minutes}`; const html = `
🕒 ${timeString} | IP ${clientIp}
`; res.send(html); }); app.listen(port, '0.0.0.0', () => { console.log(`Server running on port ${port}`); });