Problems with running Python CGI Scripts

E

Edward FISHER

Hey guys.
Im having problems running a python cgi. Im using the example code from:
http://www.python.org/doc/essays/pp...east/sld041.htm as writen by Van Rossum himself

I can get the script to run the python script but all that happens is that the black python box appears then disapears, the html that the python scripts should generate is never output.

My html is:

<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>A Typical HTML form</title></head>
<body>
<p align="center"><u><b><font size="5">A Typical HTML form</font></b></u></p>
<p align="center"><font size="1" color="#FF0000">*Test CGI script and HTML to
test server for correct running of python cgi scripting</font></p>
<form method='GET' action='http://www.fisherphotographics.co.uk/testcgia.pyc'>
<p align="center">Your First Name:
<input type='text' name='firstname' size="20">
<p align="center">Your Last Name: <input type='text' name='lastname' size="20">
<p align="center">Click here to submit form: <input type='submit' value='Yeah!'>
<input type='hidden' name='session' value='1f9a2'>
</form></body></html>

This is calling the pyc file of the python script. I dont understand why if i call the py file itself all i get returned is the plain text of the python file.

The python script is:

#!/usr/local/bin/python
import cgi

def main():
print "Content-type: text/html\n"
form = cgi.FieldStorage()
if form.has_key("firstname") and form["firstname"].value != "":
#if form has an object called firstname and the value is not an empty string
print "<h1>Hello", form["firstname"].value, "</h1>"
else:
print "<h1>Error! Please enter first name.</h1>"

main()

If you need to see what happens then follow this link:
http://www.fisherphotographics.co.uk/testhtml1.htm

The python file has come directly from the example so i must me doing something wrong. I have all the correct permissions etc
Thanks very much
Ed Fisher
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top