🚀 Express.js
Beginner
How do you create a basic Express.js server?
Answer
Install Express with npm install express, then create a server in a few lines: const express = require('express'); const app = express(); app.get('/', (req, res) => res.send('Hello World')); app.listen(3000);. express() creates an application instance. app.get() registers a route handler for HTTP GET requests. The handler receives a req (request) and res (response) object. res.send() sends a response. app.listen(port) starts the HTTP server. This is all you need for a minimal web server. In modern Node.js projects you can also use ES modules with import express from 'express' if your package.json has "type": "module".