PLEASE Help with CGI Problem!
Gerhard Häring
gerhard.nospam at bigfoot.de
Tue May 1 18:50:20 EDT 2001
Ben Ocean wrote:
>
> Hi;
> I NEED to get data from the buffer after it is sent to me from a foreign
> host. Here's (apparently) how this would be scripted in perl:
> >>>
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs = split(/&/, $buffer);
> foreach $pair (@pairs) {
> ($name, $value) = split(/=/, $pair);
> $value =~ tr/+/ /;
> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> $FORM{$name} = $value;
> }
> <<<
> How would I script it in Python and what modules must I call?
I could tell you how to do this in Python, but there is *really* no need
to. The Perl snippet just parses a CGI POST request. Use the cgi module
and cgi.FieldStorage().
Gerhard
--
Sorry for the fake email, please use the real one below to reply.
contact: g e r h a r d @ b i g f o o t . d e
web: http://highqualdev.com
More information about the Python-list
mailing list