File size: 2,549 Bytes
445d230
 
 
940b75e
 
 
 
 
 
445d230
940b75e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
445d230
 
940b75e
445d230
940b75e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
445d230
 
940b75e
 
 
445d230
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
const express = require('express');
const app = express();

const port = process.env.PORT || 7860;

// Serve static files (if you have public folder)
app.use(express.static('public'));

// Main web interface
app.get('/', (req, res) => {
  res.send(`
    <!DOCTYPE html>
    <html>
    <head>
      <title>TraffMonetizer Dashboard</title>
      <style>
        body { 
          font-family: Arial, sans-serif; 
          max-width: 800px; 
          margin: 40px auto; 
          padding: 20px; 
          background: #f5f5f5;
        }
        .container { 
          background: white; 
          padding: 30px; 
          border-radius: 10px; 
          box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        h1 { color: #333; }
        .status { 
          padding: 10px; 
          background: #4CAF50; 
          color: white; 
          border-radius: 5px;
          display: inline-block;
        }
        .info { margin: 20px 0; }
      </style>
    </head>
    <body>
      <div class="container">
        <h1>🚀 TraffMonetizer Dashboard</h1>
        <div class="info">
          <p><strong>Status:</strong> <span class="status">Active</span></p>
          <p><strong>Service:</strong> TraffMonetizer CLI + Express</p>
          <p><strong>Port:</strong> ${port}</p>
          <p><strong>Time:</strong> <span id="time">${new Date().toLocaleString()}</span></p>
        </div>
        <div>
          <h3>Endpoints:</h3>
          <ul>
            <li><a href="/">Home</a></li>
            <li><a href="/health">Health Check</a></li>
            <li><a href="/status">Service Status</a></li>
          </ul>
        </div>
        <p>This service is running TraffMonetizer in background.</p>
      </div>
      
      <script>
        // Update time every second
        function updateTime() {
          document.getElementById('time').textContent = new Date().toLocaleString();
        }
        setInterval(updateTime, 1000);
      </script>
    </body>
    </html>
  `);
});

// Health endpoint
app.get('/health', (req, res) => {
  res.json({ 
    status: 'healthy',
    service: 'traffmonetizer-express',
    timestamp: new Date().toISOString(),
    port: port
  });
});

// Status endpoint
app.get('/status', (req, res) => {
  res.json({
    traffmonetizer: 'running',
    express: 'running',
    uptime: process.uptime(),
    memory: process.memoryUsage()
  });
});

app.listen(port, '0.0.0.0', () => {
  console.log(`✅ Web interface available on port ${port}`);
  console.log(`✅ TraffMonetizer running in background`);
});