Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old September 2nd, 2008, 08:37 PM
Newbie
 
Join Date: Jun 2007
Posts: 15
Default 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
Reply
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles