Week#4 Python
Week#4 Python
Purpose: It defines how messages are formatted and transmitted, and how web servers
and browsers should respond to various commands.
HTTP/1.1 is the most common version; HTTP/2 and HTTP/3 are faster versions introduced for
efficiency.
Key Characteristics:
Client:
The user's web browser or application requesting resources (e.g., Chrome, Firefox).
Server:
Communication:
The client sends HTTP requests, and the server sends HTTP responses.
Example:
Typing a URL in the browser sends a request to the server, which returns a webp
The Client-Server Model
Diagram:
Structure of an HTTP Request
Headers: Provide additional information about the request (e.g., User-Agent, Host).
Body: Optional. Data being sent to the server (e.g., form submissions).
Common HTTP Methods
HEAD: Similar to GET but without the response body (fetches headers).
Apache:
Nginx:
Body: The actual data (HTML, JSON, images, etc.) returned by the server.
HTTP Status Codes
2xx (Success): Request successfully received, understood, and accepted (e.g., 200 OK).
3xx (Redirection): Further action needed to complete the request (e.g., 301 Moved
Permanently).
4xx (Client Error): The request contains bad syntax or cannot be fulfilled (e.g., 404 Not
Found).
5xx (Server Error): The server failed to fulfill a valid request (e.g., 500 Internal Server Error).
Understanding Web Servers
A web server is software that serves web pages in response to HTTP requests.
Hosts websites and handles requests for static (e.g., HTML) and dynamic content (e.g.,
A web server can also act as a reverse proxy, handling traffic between clients and multiple
servers.
The Role of DNS in HTTP Requests
Process:
HTTP:
HTTPS:
Static Content: Directly served from file storage (e.g., HTML, CSS, JavaScript).
Dynamic Content: Generated on-the-fly using server-side scripts (e.g., PHP, Python).
Database Connection: Web servers often interact with databases (e.g., MySQL) to retrieve or store
data
Conclusion
HTTP is the backbone of web communication, facilitating data transfer between clients and
servers.
Web servers play a critical role in delivering both static and dynamic content.
The evolution of HTTP, from HTTP/1.1 to HTTPS, has enhanced the speed, security, and
performance of the web.