http.createServer()
Creates an HTTP server instance that calls a request handler function for each incoming request.
Syntax
nodejs
http.createServer((req, res) => { })Example
nodejs
const http = require("http");
const server = http.createServer((req, res) => {
res.writeHead(200, { "Content-Type": "text/plain" });
res.end("Hello, World!");
});
server.listen(3000, () => console.log("Server running"));