const http = require('http'); // Function to generate a 4-digit PIN function generatePin() { return Math.floor(1000 + Math.random() * 9000).toString(); } const server = http.createServer((req, res) => { if (req.url === '/') { const pin = generatePin(); const html = ` 4-Digit PIN Generator

Random 4-Digit PIN Generator

${pin}
`; res.writeHead(200, {'Content-Type': 'text/html'}); res.end(html); } else { res.writeHead(404, {'Content-Type': 'text/plain'}); res.end('404 Not Found'); } }); const PORT = process.env.PORT || 3000; server.listen(PORT, () => { console.log(`Server running at http://localhost:${PORT}/`); });