467,926 Members | 1,751 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,926 developers. It's quick & easy.

Problems with running Python CGI Scripts

Hey guys.
Im having problems running a python cgi. Im using the example code from:
http://www.python.org/doc/essays/ppt...ast/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
Sep 2 '08 #1
  • viewed: 1350
Share:

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Rolfe | last post: by
4 posts views Thread by Tim Isakson | last post: by
4 posts views Thread by Peter Otten | last post: by
6 posts views Thread by Ishpeck | last post: by
24 posts views Thread by Mark | last post: by
reply views Thread by Yansky | last post: by
7 posts views Thread by Yansky | last post: by
reply views Thread by Gabriel Genellina | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.