raw post data

:B nerdy thoa0025 at mail.usyd.edu.au
Tue Sep 17 08:11:55 EDT 2002

yeah good guess! and thats something that looks like it will werk =B


"Alex Martelli" <aleax at aleax.it> wrote in message
news:siAh9.118475$pX1.4269024 at news2.tin.it...
> :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