Skip to Content
Perl To Python Migration
book

Perl To Python Migration

by Martin C. Brown
November 2001
Beginner
320 pages
5h 53m
English
Pearson Business
Content preview from Perl To Python Migration

BASIC CGI PROGRAMMING

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Perl in a Nutshell

Perl in a Nutshell

Nathan Patwardhan, Ellen Siever, Stephen Spainhour
Perl by Example

Perl by Example

Ellie Quigley
Perl Hacks

Perl Hacks

Chromatic, Damian Conway, Curtis Ovid Poe, Curtis (Ovid) Poe

Publisher Resources

ISBN: 0201734885Purchase book