Learning Python Network Programming

(Sean Pound) #1

Applications for the Web


What's in a web server?


To understand how we can employ Python in responding to HTTP requests, we
need to know a bit about what typically needs to occur in order to respond to a
request, and what tools and patterns already exist to do this.


A basic HTTP request and response might look like this:


Here our web client sends an HTTP request to a server, where a web server program
interprets the request, creates a suitable HTTP response, and sends it back. In this
case, the response body is simply the contents of an HTML file read from, with the
response headers added by the web server program.


The web server is responsible for the entire process of responding to the client's
request. The basic steps it needs to perform are:

Free download pdf