The underlying HTTP architecture explanation with implementation in python

An overview of HTTP

HTTP protocol simple diagram

How does it work?

Implementation

import socketserver = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ip = "127.0.0.1" # localhost
port = 4545 # arbitrary port number
server.bind((ip, port))
server.listen()
while True:
client, addr = server.accept()
request = client.recv(4096).decode()
page = "<h1>Hello world</h1>"
page = "<h1>Hello world</h1>" # the page
while True:
client, addr = server.accept() # accepting conn
request = client.recv(4096).decode() # receving request
print(request)
client.send("HTTP/1.1 200 OK\r\n\r\n".encode())#sending the ack
client.send(page.encode()) # sending the page
client.close() # Closing the connection
import socketserver = socket.socket(socket.AF_INET, socket.SOCK_STREAM)ip = "127.0.0.1" # localhost
port = 4545 # arbitrary port number
server.bind((ip, port))
server.listen()page = "<h1>Hello world</h1>" # the pagewhile True:
client, addr = server.accept() # accepting conn
request = client.recv(4096).decode() # receving request
print(request)
client.send("HTTP/1.1 200 OK\r\n\r\n".encode())#sending the ack
client.send(page.encode()) # sending the page
client.close() # Closing the connection

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abdella Solomon

Abdella Solomon

A 17yo Data Scientist | Programmer | Writer | Freelancer | Lecturer