I've mod_php installed with Apache 2.2. In one of my folders, I'm
using the cgihandler as the PythonHandler as my target host runs
python only as CGI. Here cgi.FieldStorag e() doesn't seem to work. I
can see the form data in sys.stdin but cgi.FieldStorag e() returns an
empty dictionary. Here's the code for the test script I am posting to
-
--
#!/usr/bin/python
import os
import cgi
import sys
print "Content Type: text/plain\n\n"
print "Hello CGI World !\n"
for key in os.environ:
print key + "= " + os.environ[key]
print cgi.FieldStorag e()
print sys.stdin.read( )
--
And here's the output I see ..
--
Hello CGI World !
HTTP_REFERER= http://learnpython/form.htm
SERVER_SOFTWARE = Apache/2.2.4 (Win32) mod_python/3.3.1 Python/2.5.1
SCRIPT_NAME= /mptest.py
SERVER_SIGNATUR E=
REQUEST_METHOD= POST
SERVER_PROTOCOL = HTTP/1.1
QUERY_STRING= abc=ayz
PATH= C:\Program Files\Internet Explorer;;C:\WI NDOWS\system32; C:
\WINDOWS;C:\WIN DOWS\System32\W bem;q:\bin;m:\c m\clearcase\bin ;M:\PERL\NT
\EXEC\BIN;m:\cm \clearcase\bin\ nt;M:\Perl\NT\E XEC\BIN;m:\perl \nt\exec
\bin;m:\cm\clea rcase\utils;q:\ bin;m:\opus;m:\ tvcs;C:\highc33 1\bin;C:
\Program Files\Rational\ ClearCase\bin;C :\Program Files\Rational\ common
CONTENT_LENGTH= 86
HTTP_USER_AGENT = Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;
SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
HTTP_CONNECTION = Keep-Alive
SERVER_NAME= learnpython
REMOTE_ADDR= 127.0.0.1
PATHEXT= .COM;.EXE;.BAT; .CMD;.VBS;.VBE; .JS;.JSE;.WSF;. WSH
SERVER_PORT= 80
SERVER_ADDR= 127.0.0.1
DOCUMENT_ROOT= D:/Projects/LearnPython/www
COMSPEC= C:\WINDOWS\syst em32\cmd.exe
SCRIPT_FILENAME = D:/Projects/LearnPython/www/mptest.py
SERVER_ADMIN= pu**********@te kelec.com
HTTP_HOST= learnpython
SystemRoot= C:\WINDOWS
HTTP_CACHE_CONT ROL= no-cache
REQUEST_URI= /mptest.py?abc=a yz
HTTP_ACCEPT= */*
WINDIR= C:\WINDOWS
GATEWAY_INTERFA CE= Python-CGI/1.1
REMOTE_PORT= 1081
HTTP_ACCEPT_LAN GUAGE= en-us
CONTENT_TYPE= application/x-www-form-urlencoded
HTTP_ACCEPT_ENC ODING= gzip, deflate
FieldStorage(No ne, None, [])
firstName=punee t&address=hawai i
--
I am posting to this script using a form with two text fields named
firstName and address.
any clue where am I going wrong ?
thanks,
regards,
-Puneet.