Begginer's Guide to Python, CGI
Python is an excellent language for writing CGI scripts. All of the examples here will assume you have the Apache http server running on a UNIX/Linux/cygwin system. If you are using a different http server or operating system, consult the documentation that came with that system for instructions on running CGI scripts.
Your first Python CGI script
Writing a CGI script in Python is exceedingly easy. Here is an example:
This example assumes your Python interpreter is located in /usr/bin. Change this to reflect your system. Save this example as a text file in your cgi-bin directory (/var/www/cgi-bin on my system). To run your script and see the output, just point your browser to "[your domain name]/cgi-bin/plain.py".
print "Content-type: text/plain\n"
print "Hello, CGI world!"
last edited (December 30, 2002) by infidel
Back to the page