Update index.js
Browse files
index.js
CHANGED
|
@@ -1,16 +1,96 @@
|
|
| 1 |
const express = require('express');
|
| 2 |
const app = express();
|
| 3 |
-
const port = process.env.PORT || 7860; // Render ko yahi port batana hoga
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
app.get('/', (req, res) => {
|
| 6 |
-
res.send(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
});
|
| 8 |
|
|
|
|
| 9 |
app.get('/health', (req, res) => {
|
| 10 |
-
res.json({
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
});
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
console.log(
|
| 16 |
});
|
|
|
|
| 1 |
const express = require('express');
|
| 2 |
const app = express();
|
|
|
|
| 3 |
|
| 4 |
+
const port = process.env.PORT || 7860;
|
| 5 |
+
|
| 6 |
+
// Serve static files (if you have public folder)
|
| 7 |
+
app.use(express.static('public'));
|
| 8 |
+
|
| 9 |
+
// Main web interface
|
| 10 |
app.get('/', (req, res) => {
|
| 11 |
+
res.send(`
|
| 12 |
+
<!DOCTYPE html>
|
| 13 |
+
<html>
|
| 14 |
+
<head>
|
| 15 |
+
<title>TraffMonetizer Dashboard</title>
|
| 16 |
+
<style>
|
| 17 |
+
body {
|
| 18 |
+
font-family: Arial, sans-serif;
|
| 19 |
+
max-width: 800px;
|
| 20 |
+
margin: 40px auto;
|
| 21 |
+
padding: 20px;
|
| 22 |
+
background: #f5f5f5;
|
| 23 |
+
}
|
| 24 |
+
.container {
|
| 25 |
+
background: white;
|
| 26 |
+
padding: 30px;
|
| 27 |
+
border-radius: 10px;
|
| 28 |
+
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
| 29 |
+
}
|
| 30 |
+
h1 { color: #333; }
|
| 31 |
+
.status {
|
| 32 |
+
padding: 10px;
|
| 33 |
+
background: #4CAF50;
|
| 34 |
+
color: white;
|
| 35 |
+
border-radius: 5px;
|
| 36 |
+
display: inline-block;
|
| 37 |
+
}
|
| 38 |
+
.info { margin: 20px 0; }
|
| 39 |
+
</style>
|
| 40 |
+
</head>
|
| 41 |
+
<body>
|
| 42 |
+
<div class="container">
|
| 43 |
+
<h1>π TraffMonetizer Dashboard</h1>
|
| 44 |
+
<div class="info">
|
| 45 |
+
<p><strong>Status:</strong> <span class="status">Active</span></p>
|
| 46 |
+
<p><strong>Service:</strong> TraffMonetizer CLI + Express</p>
|
| 47 |
+
<p><strong>Port:</strong> ${port}</p>
|
| 48 |
+
<p><strong>Time:</strong> <span id="time">${new Date().toLocaleString()}</span></p>
|
| 49 |
+
</div>
|
| 50 |
+
<div>
|
| 51 |
+
<h3>Endpoints:</h3>
|
| 52 |
+
<ul>
|
| 53 |
+
<li><a href="/">Home</a></li>
|
| 54 |
+
<li><a href="/health">Health Check</a></li>
|
| 55 |
+
<li><a href="/status">Service Status</a></li>
|
| 56 |
+
</ul>
|
| 57 |
+
</div>
|
| 58 |
+
<p>This service is running TraffMonetizer in background.</p>
|
| 59 |
+
</div>
|
| 60 |
+
|
| 61 |
+
<script>
|
| 62 |
+
// Update time every second
|
| 63 |
+
function updateTime() {
|
| 64 |
+
document.getElementById('time').textContent = new Date().toLocaleString();
|
| 65 |
+
}
|
| 66 |
+
setInterval(updateTime, 1000);
|
| 67 |
+
</script>
|
| 68 |
+
</body>
|
| 69 |
+
</html>
|
| 70 |
+
`);
|
| 71 |
});
|
| 72 |
|
| 73 |
+
// Health endpoint
|
| 74 |
app.get('/health', (req, res) => {
|
| 75 |
+
res.json({
|
| 76 |
+
status: 'healthy',
|
| 77 |
+
service: 'traffmonetizer-express',
|
| 78 |
+
timestamp: new Date().toISOString(),
|
| 79 |
+
port: port
|
| 80 |
+
});
|
| 81 |
+
});
|
| 82 |
+
|
| 83 |
+
// Status endpoint
|
| 84 |
+
app.get('/status', (req, res) => {
|
| 85 |
+
res.json({
|
| 86 |
+
traffmonetizer: 'running',
|
| 87 |
+
express: 'running',
|
| 88 |
+
uptime: process.uptime(),
|
| 89 |
+
memory: process.memoryUsage()
|
| 90 |
+
});
|
| 91 |
});
|
| 92 |
|
| 93 |
+
app.listen(port, '0.0.0.0', () => {
|
| 94 |
+
console.log(`β
Web interface available on port ${port}`);
|
| 95 |
+
console.log(`β
TraffMonetizer running in background`);
|
| 96 |
});
|