Web Development · Module 1 · Lesson 11 min read

Clients, Servers & HTTP

The big picture

The web is a conversation between clients (browsers, apps) and servers (computers that store websites and data).

  1. You type a URL or tap a link.
  2. The browser sends an HTTP request to a server.
  3. The server sends back an HTTP response: HTML, CSS, JavaScript, images or JSON.
  4. The browser shows the page.

Anatomy of a URL

https://shop.example.com:443/products/42?color=red#reviews

PartExampleMeaning
Protocolhttpshow to talk (secure HTTP)
Domainshop.example.comwhich server
Port443usually hidden (80 for HTTP, 443 for HTTPS)
Path/products/42which resource
Query?color=redextra parameters
Fragment#reviewsa spot on the page (never sent to the server)

HTTP methods and status codes

  • GET read, POST create, PUT/PATCH update, DELETE remove.
  • 2xx success (200 OK, 201 Created), 3xx redirect, 4xx your mistake (404 Not Found, 401 Unauthorized), 5xx server error (500).

HTTPS

HTTP inside TLS encryption: nobody in between can read or change the data, and the certificate proves the site is real. Always use HTTPS.

Front end vs back end

  • Front end: what runs in the browser (HTML, CSS, JavaScript).
  • Back end: what runs on the server (APIs, databases, authentication).
  • Full stack: both.

Example

JavaScript
// See a real HTTP request and response (paste into the JS editor or a browser console)
fetch("https://jsonplaceholder.typicode.com/todos/1")
  .then((res) => {
    console.log("Status:", res.status);                       // 200
    console.log("Type:", res.headers.get("content-type"));   // application/json
    return res.json();
  })
  .then((data) => console.log(data));
// { userId: 1, id: 1, title: "...", completed: false }