“When you know the whole system and understand how different pieces fit together, you can identify and fix problems faster.”
What is a Web Server?
Its a networking server that sits on a physical server and waits for a client to send a request. When it receives a request, it generates a response and sends it back to the client using HTTP protocol.A client can be browser or any other software that speaks HTTP.

import socket
HOST, PORT = '', 8888
listen_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
listen_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
listen_socket.bind((HOST, PORT))
listen_socket.listen(1)
print(f'Serving HTTP on port {PORT} ...')
while True:
client_connection, client_address = listen_socket.accept()
request_data = client_connection.recv(1024)
print(request_data.decode('utf-8'))
http_response = b"""\
HTTP/1.1 200 OK
Hello, World!
"""
client_connection.sendall(http_response)
client_connection.close()

The response status line HTTP/1.1 200 OK consists of the HTTP Version, the HTTP status code and the HTTP status code reason phrase OK. When the browser gets the response, it displays the body of the response and that’s why you see “Hello, World!” in the browser.
In general, The Web server creates a listening socket and starts accepting new connections in a loop. The client initiates a TCP connections and, after successfully establishing it, the client sends an HTTP request to the server and the server responses with an HTTP response that gets displayed to the user. To establish a TCP connection both client and server use sockets.