the form or the address used to contact the server, is run on the server and produces
another HTML page as a reply. Along the way, data typically passes through three
programs: from the client browser, to the web server, to the CGI script, and back again
to the browser. This is a natural model for the database access interaction we’re after—
users can submit a database key to the server and receive the corresponding record as
a reply page.
We’ll go into CGI basics in depth later in this book, but as a first example, let’s start
out with a simple interactive example that requests and then echoes back a user’s name
in a web browser. The first page in this interaction is just an input form produced by
the HTML file shown in Example 1-30. This HTML file is stored on the web server
machine, and it is transferred to the web browser running on the client machine upon
request.
Example 1-30. PP4E\Preview\cgi101.html
Notice how this HTML form names the script that will process its input on the server
in its action attribute. This page is requested by submitting its URL (web address).
When received by the web browser on the client, the input form that this code produces
is shown in Figure 1-10 (in Internet Explorer here).
Figure 1-10. cgi101.html input form page
When this input form is submitted, a web server intercepts the request (more on the
web server in a moment) and runs the Python CGI script in Example 1-31. Like the
Step 6: Adding a Web Interface | 53