Guided Notes
The HTTP Module: Building a Server
Creating a server with node:http, requests and responses, routing by method and path, status codes and headers, JSON bodies, and making HTTP requests with fetch.
A server in a few lines
Slide 1 / 5const http = require("node:http");
const server = http.createServer((req, res) => { res.writeHead(200, { "Content-Type": "text/plain" }); res.end("Hello from Node!\n"); });
server.listen(3000, () => console.log("Listening on http://localhost:3000"));
Every request calls your handler with req (the incoming request: method, url, headers, body stream) and res (the response you write).
