Table of Contents
anyform.cgi: An example CGI script to show all form data
reader.cgi: An example script with cookies
main(): Main program
deleteCase(): Delete the cookie
deletionPage(): Generate the deletion-successful page
genericPage(): Build a generic Web page
chapterCase(): Present the next chapter
updateDatabase(): Update or create the user's database entry
newUserRecord(): Create the initial user record
setCookie(): Set a cookie
generateChapter(): HTML page generation
generateForm(): Build the
navButtons: Add navigational buttons
radioGroup(): Add the radiobutton group
class Inputs: All the script's input
UserDatabase.__getitem__(): Implement dictionary get
Most Web pages are static: the
same content appears each time you visit that URL. To put
up static content, you simply place a file in or under a
specific directory, and give it a name that ends in
.html”. If your page is
hosted at the New Mexico Tech Computer Center (TCC), static
pages must reside in subdirectory “
public_html” under your home directory.
This document describes technique for dynamic web pages: their content is generated on demand. This technique is called CGI, for Common Gateway Interface. Instead of writing the page's content, you will write a program that generates the content as its output. Such a program is called a CGI script (nowadays the terms “script” and “program” are pretty much interchangeable). The program can be written in just about any modern programming language. We'll describe how to do it in the Python language, a very good modern general-purpose programming language.
One of the commonest uses for dynamic web pages is to handle forms. For example, you might put up a web page displaying a form that allows the user to enter search terms for a database query. When they click on thebutton, a new page appears that displays the results of their query.
However, dynamic web pages are useful for other applications besides forms handling. For example, you might put up a “Site Map” link that takes the user to an interactive site map. An example is the site map for the TCC Help System.