19.5. Building CGI Application

19.5.1. Generating the Results Page

In Example 19.2, we present the code for a simple Web form, friends.htm.

Listing 19.2. Static Form Web Page (friends.htm)

This HTML file presents a form to the user with an empty field for the user's name and a set of radio buttons for the user to choose from.

1   <HTML><HEAD><TITLE>
2   Friends CGI Demo (static screen)
3   </TITLE></HEAD>
4   <BODY><H3>Friends list for: <I>NEW USER</I></H3>
5   <FORM ACTION="/cgi-bin/friends1.py">
6   <B>Enter your Name:</B>
7   <INPUT TYPE=text NAME=person SIZE=15>
8   <P><B>How many friends do you have?</B>
9   <INPUT TYPE=radio NAME=howmany VALUE="0"> CHECKED> 0
10  <INPUT TYPE=radio NAME=howmany VALUE="10"> 10
11  <INPUT TYPE=radio NAME=howmany VALUE="25"> ...

Get Core Python Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.