DEV Community

Fiyinfoluwa Ojo
Fiyinfoluwa Ojo

Posted on

HTTP & The Request Response Cycle: What Really Happens When You Hit Enter

Ever wondered what actually happens when you type a URL and hit Enter?
It's not magic, it's HTTP.

What is HTTP?

HTTP (HyperText Transfer Protocol) is the language browsers and servers
use to talk to each other. Every time you visit a website, your browser
sends an HTTP request and the server sends back an HTTP response.

The Request Response Cycle

Here's how it works step by step:

  1. You type https://example.com in your browser
  2. Your browser sends a REQUEST to the server
  3. The server processes it
  4. The server sends back a RESPONSE
  5. Your browser displays the result

Simple as that!

HTTP Methods

  • GET : fetch data
  • POST: send data
  • PUT : update data
  • DELETE : remove data

Status Codes

  • 200 : Success
  • 404 : Not Found
  • 500 : Server Error

First Endpoint

For Day 1 of the GDGoC Bowen 30 Day Challenge, I built a simple
Hello World API using FastAPI (Python):

from fastapi import FastAPI

app = FastAPI()

@app.get("/")
def hello():
    return {"msg": "hello"}

Enter fullscreen mode Exit fullscreen mode

Hit the endpoint and it returns:
{"msg": "hello"}

Here's the live response from my FastAPI server:

Hello endpoint response in FastAPI docs

About endpoint response in FastAPI docs
That's the request-response cycle in action!

Lessons Learned

HTTP is the foundation of everything on the web.
Before you can build APIs, authentication, databases
you need to understand how client and server communicate.

Day 1 done. 29 more to go.

GDGoCBowen30dayChallenge

Top comments (0)