CGI? and other stuff with python

Gerhard Haering gerhard.haering at
Thu Aug 8 02:45:04 EDT 2002

"Patio87" wrote:
>     I was wondering what kind of stuff Python can do for me? I have a good
>     grip on the basics of Python and want to do more. I saw something on CGI
>     but I have no idea what that is.

CGI stands for "Common Gateway Interface" and is a way to have dynamic content
created by a webserver. You can configure your webserver to treat files in a
particular directory as "CGI scripts", which will be invoked for certain
requests. A common configuration is that you have a cgi-bin directory somewhere
on your machine and have configured your webserver so that it searches for CGI
scripts in the cgi-bin directory for requests that start with "/cgi-bin/". An example:

You have set up a local webserver and enter the following URL into your browser:
The webserver (if configured to do so) should then search for a file in
the cgi-bin directory and execute it.

A minimal CGI script in Python will look like:

# Print the HTTP header, here only one header that tells the web browser
# which type of document this is.
print "Content-type: text/html"

# Separate HTTP header and body

# Output a minimal HTML document
print """

If you want to give your CGI scripts parameters, for example to handle what a
user entered into a form, you'll want the cgi module to get easy access to
these inputs.

> If you could tell me some stuff that Python can do, and what CGI is I will be
> very happy. I am not the smartest person on computer dialouge and am 15 so if
> you could keep the level of words down to a newbie of python i will
> understand


mail:   gerhard <at> bigfoot <dot> de       registered Linux user #64239
web:    OpenPGP public key id 86AB43C0
public key fingerprint: DEC1 1D02 5743 1159 CD20  A4B6 7B22 6575 86AB 43C0
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))

More information about the Python-list mailing list