Like GUIs, web-based systems are highly interactive, and the best way to get a feel for some of these examples is to test-drive them live. Before we get into some code, let’s get set up to run the examples we’re going to see.
Running CGI-based programs requires three pieces of software:
The client, to submit requests: a browser or script
The web server that receives the request
The CGI script, which is run by the server to process the request
We’ll be writing CGI scripts as we move along, and any web
browser can be used as a client (e.g., Firefox, Safari, Chrome, or
Internet Explorer). As we’ll see later, Python’s
urllib.request module can also serve as a web client in scripts we
write. The only missing piece here is the intermediate web
There are a variety of approaches to running web servers. For
example, the open source Apache system provides a complete,
production-grade web server, and its
extension discussed later runs Python scripts quickly. Provided you
are willing to install and configure it, it is a complete solution,
which you can run on a machine of your own. Apache usage is beyond
our present scope here, though.
If you have access to an account on a web server machine that runs Python 3.X, you can also install the HTML and script files we’ll see there. For the second edition of this book, for instance, all the web examples were uploaded to an account I had on the “starship” Python server, and were accessed with ...