Page 335 -
P. 335
manage your data
Test Drive
Here’s the code to a CGI script called cgi-bin/test-form.py, which generates the HTML form
from earlier. As you can see, there’s nothing to it.
#! /usr/local/bin/python3
Always start with a Dynamically create the form,
CGI response. supplying any arguments as required.
import yate
print(yate.start_response('text/html'))
print(yate.do_form('add_timing_data.py', ['TimeValue'], text='Send'))
Set the executable bit (if required on your OS) using chmod + x test_form.py , and then use
your browser to confirm that your HTML form-generating code is working.
Enter the URL for the CGI script into
your web browser’s location bar.
Use your browser’s
“View Source” menu
option to confirm that
the generated form is
exactly what you need.
The generated HTML
form appears within
the browser’s window.
Great. You’ve extended yate.py to support the creation of a simple data
entry form. Now all you need to do is to decide what happens once the data
arrives on your server.
you are here 4 299

