node / index.js
kamiwork's picture
Update index.js
940b75e verified
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`);
});