CGI module does not parse data

Devan L devlai at gmail.com
Fri Dec 16 22:15:34 EST 2005


amfr wrote:
> I am writing a webserver, and I want it to be able to run python
> scripts.  But when I set sys.stdin to self.rfile (using the
> BaseHTTPServer class, self.rfile is a input stream containing the
> request), the cgi module does not parse the data.
> Example script:
> import cgi
> form = cgi.FieldStorage()
> print form["testfield"]
>
> The above script would print nothing.  Should i be setting sys.stdin to
> something else, or is there anthoer solution entirely?
try this before trying to print:
    print "Content-Type: text/html\n"




More information about the Python-list mailing list