Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
// Event Loop phases (simplified): // 1. timers — setTimeout / setInterval callbacks // 2. I/O — completed I/O callbacks // 3. poll — retrieve new I/O events // 4. check — setImmediate callbacks // 5. close — close event callbacks // ---- Your first HTTP server ---- const http = require('http'); const server = http.createServer((req, res) => { res.writeHead(200, { 'Content-Type': 'text/plain' }); res.end('Hello, World! '); }); const PORT = 3000; server.listen(PORT, () => { console.log(`Server running at http://localhost:${PORT}/`); }); // Visit http://localhost:3000 in your browser. // Node.js handles each request asynchronously, // so the server keeps listening for more requests.
Result
Open