This problem is probably awkwardly simple.
I'm trying to give python a spin. I thought that a good way to start this would be to create a simple cgi script to process data in a certain form and create some magic. My python script runs apache correctly with mod_python and prints everything I want it to print.
My only problem is that cgi.FieldStorage () is always empty . I tried using both POST and GET. In each test, I fill out both form fields.
<form action="pythonScript.py" method="POST" name="ARGH">
<input name="TaskName" type="text" />
<input name="TaskNumber" type="text" />
<input type="submit" />
</form>
If I change the form to point to a perl script, it correctly reports the form data. The python page always gives me the same result: number of keys: 0
import cgi
def index(req):
pageContent = """<html><head><title>A page from"""
pageContent += """Python</title></head><body>"""
form = cgi.FieldStorage()
keys = form.keys()
keys.sort()
pageContent += "<br />number of keys: "+str(len(keys))
for key in keys:
pageContent += fieldStorage[ key ].value
pageContent += """</body></html>"""
return pageContent
Python 2.5.2 Apache/2.2.3. , apache conf ( script /var/www/python ):
<Directory /var/www/python/>
Options FollowSymLinks +ExecCGI
Order allow,deny
allow from all
AddHandler mod_python .py
PythonHandler mod_python.publisher
</Directory>