Includes a Node.js HTTP server, static HTML page, and Dockerfile for containerized self-hosting. Exposes a /health endpoint for platform health checks. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
30 lines
838 B
JavaScript
30 lines
838 B
JavaScript
const http = require('http');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const PORT = process.env.PORT || 3000;
|
|
|
|
const server = http.createServer((req, res) => {
|
|
if (req.url === '/' || req.url === '/index.html') {
|
|
const filePath = path.join(__dirname, 'index.html');
|
|
fs.readFile(filePath, (err, data) => {
|
|
if (err) {
|
|
res.writeHead(500);
|
|
res.end('Error loading page');
|
|
return;
|
|
}
|
|
res.writeHead(200, { 'Content-Type': 'text/html' });
|
|
res.end(data);
|
|
});
|
|
} else if (req.url === '/health') {
|
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
res.end(JSON.stringify({ status: 'ok' }));
|
|
} else {
|
|
res.writeHead(404);
|
|
res.end('Not found');
|
|
}
|
|
});
|
|
|
|
server.listen(PORT, () => {
|
|
console.log(`Server running on http://localhost:${PORT}`);
|
|
});
|