50 Mins

1. How the Web Works (HTTP Deep Dive)

Bridge Module 1

How the Web Actually Works

Before you can build a backend, you need to understand the conversation that happens between your browser and a server. Every time you visit a website, send a message, or load an app, this exact conversation happens — usually in less than a second.

The Request-Response Cycle

Every single interaction on the web follows the same pattern:

Your Browser (Client)
asks for data
->️ REQUEST <-️
A Server
processes the request
->️ RESPONSE <-️
Your Browser
receives the data

The Client is always the one asking. The Server is always the one waiting and answering. A server is just a computer that runs a program that does nothing but listen — patiently waiting for someone to ask it for something.

HTTP Methods (The Verbs)

The HTTP method tells the server what kind of action you want to perform. Think of these as verbs in a sentence.

GET

Retrieve data. Never changes anything. Example: Loading a list of products.

POST

Send new data to create something. Example: Creating a new user account.

PUT / PATCH

Update existing data. Example: Changing your email address.

DELETE

Remove existing data. Example: Deleting a post.

Remember: GET is for reading. POST is for creating. PUT/PATCH is for updating. DELETE is for removing. That's 95% of what you'll do.

HTTP Status Codes (The Server's Reply)

Every response from a server includes a three-digit status code that tells you what happened.

2xx — Success

200 OK = Everything worked
201 Created = New resource made

4xx — Client Error

400 Bad Request = You sent bad data
401 Unauthorized = You need to log in
403 Forbidden = You're logged in but not allowed
404 Not Found = That URL doesn't exist

5xx — Server Error

500 Internal Server Error = The server crashed
502 Bad Gateway = Something broke in between

Text
Example: When you visit https://api.example.com/users/5

If user exists → 200 OK with user data
If user doesn't exist → 404 Not Found
If you're not logged in → 401 Unauthorized
If the server crashes → 500 Internal Server Error
Critical Rule: Never return a 200 OK with an error message inside. That's like a waiter saying <strong><code>Everything's fine while giving you the wrong food. The status code MUST match what actually happened.

Try It Yourself (Concept Check)

You don't need to write code yet. Just understand the logic:

Scenario 1: You want to see a list of all productsMethod: GET URL: /products Expected Status: 200 OK (if successful)
Scenario 2: You want to create a new user accountMethod: POST URL: /users Expected Status: 201 Created (if successful)
Scenario 3: You try to view a profile that doesn't existMethod: GET URL: /users/99999 Expected Status: 404 Not Found

Knowledge Check

Ready to test your understanding of 1. How the Web Works (HTTP Deep Dive)?

Back