โ demos
/
๐ฆ vibeclaw
/
HTTP Server
http ยท require()
server.js
Run Server
const http = require('http'); const server = http.createServer((req, res) => { console.log(`${req.method} ${req.url}`); if (req.url === '/') { res.setHeader('Content-Type', 'text/html'); res.end(` <!DOCTYPE html> <html> <head> <style> body { font-family: system-ui, sans-serif; padding: 2rem; background: #0c0c0c; min-height: 100vh; margin: 0; display: flex; align-items: center; justify-content: center; color: #c0c0c0; } .card { border: 1px solid #2a2a2a; padding: 2rem; max-width: 480px; } h1 { color: #ff5c5c; margin-top: 0; } a { color: #ff5c5c; } </style> </head> <body> <div class="card"> <h1>Agent Runtime Active</h1> <p>This HTTP server is running inside an isolated browser runtime.</p> <p>Try <a href="/api/time">/api/time</a> or <a href="/api/random">/api/random</a></p> </div> </body> </html> `); } else if (req.url === '/api/time') { res.setHeader('Content-Type', 'application/json'); res.end(JSON.stringify({ time: new Date().toISOString() })); } else if (req.url === '/api/random') { res.setHeader('Content-Type', 'application/json'); res.end(JSON.stringify({ random: Math.random() })); } else { res.statusCode = 404; res.end('Not Found'); } }); server.listen(3000, () => { console.log('Server running on port 3000'); });
Preview
Ready
Console