Learning Python Network Programming

(Sean Pound) #1
Chapter 9

CGI


In the early days of the Web, web servers would mostly only be required to send
clients HTML pages, or the occasional image file. As in the earlier figure of a HTTP
request journey, these static resources would live on the hard disk of the server, and
the web server's main task would be to accept socket connections from clients, map
the URL of a request to a local file, and send the file back over the socket as an
HTTP response.


However, with the rise of the need for dynamic content, web servers were given
the ability to generate pages by invoking external programs and scripts, which we
today call web applications. Web applications originally took the form of scripts or
compiled executables that lived on disk next to the regular static content as part of
the published web tree. The web server would be configured so that when a client
requested these web application files, instead of just reading the file and returning
it, the web server would launch a new operating system process and execute the file,
returning the result as the requested HTML web page.


If we update our HTTP request's journey from our earlier image, our request's
journey would now look something like this:

Free download pdf