A simple demonstration of client-server architecture using Node.js and Express.
npm install
npm startThen open http://localhost:3000 in your browser.
server.js- Express server with REST API endpoints (GET /api/users,POST /api/users)public/index.html- HTML page with buttonspublic/style.css- CSS styles for the HTML pagepublic/script.js- Client-side JavaScript usingfetch()API to make HTTP requests
Server: Express serves static files and handles REST API requests. Uses in-memory array for data storage.
Client: HTML page with buttons that trigger JavaScript functions in script.js. The fetch() API sends HTTP requests to the server and updates the DOM with responses.
- Request-response cycle
- HTTP methods (GET, POST)
- JSON communication
- REST API endpoints
- Client-side JavaScript with
fetch()