Python and the Web
Using some of the techniques discussed in this book, in particular Chapter 8, Client and Server Applications, it is possible to use Python to write a full web server that handles all four of the steps of handling an HTTP request that we listed in the previous section. There are several actively developed web servers already in existence written in pure Python, including Gunicorn (http://gunicorn.org), and CherryPy (http://www.cherrypy.org). There is even a very basic HTTP server in the standard library http.server module.
Writing a full HTTP server is not a trivial task and a detailed treatment is well beyond the scope of this book. It is also not a very common requirement nowadays, primarily due to the prevalence of excellent web servers that are already ready to deploy. If you do feel the need to have a crack at this challenge though, I would start with looking through the source code of the web servers mentioned earlier, looking in more detail at the frameworks listed...