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 or Internet Explorer).
As we’ll see later, Python’s
module can also serve as a web client in scripts we write. The only
missing piece here is the intermediate web server.
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
mod_python extension discussed later runs
Python scripts quickly. Provided you are willing to install and
configure, it is a complete solution, which you can run on a machine
of your own. Apache usage is beyond our present scope here,
If you have access to an account on a web server machine that runs Python, 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 URLs of this form: