November 2001
Beginner
320 pages
5h 53m
English
The basic process of setting up your Python based CGI application is to start by sending back the HTTP header. The Python cgi module does not provide any solutions for generating this information for you. This means that you will need to translate any CGI module instructions of the form:
use CGI;
my $query = new CGI;
print $query->header('text/html');
into a Python print statement:
print 'Content-type: text/html\r\n\r\n',
To get the information supplied to fields in a form, the easiest method is to use the param() function in the Perl CGI module:
use CGI;
my $name = param('name');
my @options = param('options');
In Python this translates to using the getvalue() function:
import cgi name = cgi.getvalue('name') options ...