Create index.js
Browse files
index.js
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const express = require('express');
|
2 |
+
const app = express();
|
3 |
+
const port = process.env.PORT || 7860;
|
4 |
+
const requestIp = require('request-ip');
|
5 |
+
|
6 |
+
app.use(express.static('public'));
|
7 |
+
|
8 |
+
// Create a route that returns the HTML with time and IP
|
9 |
+
app.get('/', (req, res) => {
|
10 |
+
const clientIp = requestIp.getClientIp(req) || "Unknown";
|
11 |
+
|
12 |
+
// Get current time
|
13 |
+
const now = new Date();
|
14 |
+
const options = { weekday: 'short', hour: '2-digit', minute: '2-digit' };
|
15 |
+
const timeString = now.toLocaleDateString(undefined, options);
|
16 |
+
|
17 |
+
// Generate random visitor count (more realistic for Hugging Face)
|
18 |
+
const visitorCount = Math.floor(Math.random() * 30) + 15;
|
19 |
+
|
20 |
+
const html = `
|
21 |
+
<!DOCTYPE html>
|
22 |
+
<html>
|
23 |
+
<head>
|
24 |
+
<meta charset="UTF-8">
|
25 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
26 |
+
<style>
|
27 |
+
body, html {
|
28 |
+
margin: 0;
|
29 |
+
padding: 0;
|
30 |
+
height: 100%;
|
31 |
+
font-family: Arial, sans-serif;
|
32 |
+
}
|
33 |
+
.container {
|
34 |
+
display: flex;
|
35 |
+
align-items: center;
|
36 |
+
padding: 8px 12px;
|
37 |
+
background: linear-gradient(135deg, #ff0844 0%, #8000ff 50%, #0061ff 100%);
|
38 |
+
border-radius: 6px;
|
39 |
+
color: white;
|
40 |
+
height: 100%;
|
41 |
+
box-sizing: border-box;
|
42 |
+
}
|
43 |
+
.clock-emoji {
|
44 |
+
margin-right: 8px;
|
45 |
+
font-size: 16px;
|
46 |
+
}
|
47 |
+
.info-text {
|
48 |
+
font-size: 14px;
|
49 |
+
white-space: nowrap;
|
50 |
+
overflow: hidden;
|
51 |
+
text-overflow: ellipsis;
|
52 |
+
}
|
53 |
+
</style>
|
54 |
+
</head>
|
55 |
+
<body>
|
56 |
+
<div class="container">
|
57 |
+
<span class="clock-emoji">🕒</span>
|
58 |
+
<span class="info-text">${timeString} • Online: ${visitorCount} • IP: ${clientIp}</span>
|
59 |
+
</div>
|
60 |
+
<script>
|
61 |
+
// Reload the page every minute to update time
|
62 |
+
setTimeout(() => {
|
63 |
+
window.location.reload();
|
64 |
+
}, 60000);
|
65 |
+
</script>
|
66 |
+
</body>
|
67 |
+
</html>
|
68 |
+
`;
|
69 |
+
|
70 |
+
res.send(html);
|
71 |
+
});
|
72 |
+
|
73 |
+
app.listen(port, '0.0.0.0', () => {
|
74 |
+
console.log(`Server running on port ${port}`);
|
75 |
+
});
|