raw post data
Alex Martelli
aleax at aleax.it
Tue Sep 17 02:52:08 EDT 2002
:B nerdy wrote:
> how could i make it so when i read the stdin it still is there.. cause i
> use cgi.FormVariables() also
When you instantiate class cgi.FieldStorage (there's no such
thing as cgi.FormVariables, so I'm just guessing at what it IS
that you want!) you can pass it an optional first parameter
that is a file object open for reading -- it uses sys.stdin
as the default if you don't pass the first parameter.
Thus, the following should work (untested!):
import cgi, sys, cStringIO
copyInput = cStringIO.StringIO(sys.stdin.read())
fieldStorage = cgi.FieldStorage(copyInput)
The raw posted data are now available as the string returned
by calling copyInput.getvalue(), and are also parsed by cgi to
obtain fieldStorage.
Alex
More information about the Python-list
mailing list