Page 274 -
P. 274
cgi script
Pool Puzzle Solution
Your job was to take the code from the pool
and place them into the blank lines in the
CGI script. You were not to use the same
line of code more than once. Your goal
was to make a CGI script that generates a
HTML page that matches the hand-drawn
design.
import athletemodel
import yate
import glob
Start generating the
web page, providing an
Always start with a data_files = glob.glob("data/*.txt") appropriate title.
Content-type line. athletes = athletemodel.put_to_store(data_files)
Start generating print(yate.start_response()) A paragraph telling
the form, print(yate.include_header("Coach Kelly's List of Athletes")) your user what to
providing the name print(yate.start_form("generate_timing_data.py")) do
of the server- print(yate.para("Select an athlete from the list to work with:"))
side program to
link to.
for each_athlete in athletes:
Generate a radio- print(yate.radio_button("which_athlete", athletes[each_athlete].name))
button for each of print(yate.end_form("Select")) End the form generation with a custom
“Submit” button.
your athletes. print(yate.include_footer({"Home": "/index.html"}))
Cool…an
empty pool.
238 Chapter 7