using "request" variable in python web program

Paul Boddie paul at boddie.org.uk
Mon Oct 22 12:31:38 CEST 2007


On 22 Okt, 10:34, sami <sami.... at gmail.com> wrote:
> > See the library reference for information on how to get the value of
> > form/request parameters from the CGI environment:
>
> >http://docs.python.org/lib/node561.html
>
> > Paul
>
> Thanks again Paul - now I can see that the "request" object is a
> string of name/value pairs that occurs after a "?" in a url e.g.
> url.com/index.cgi?name=sami&lang=python - is that correct? Googling
> for this information is useless since the word "request" is so common
> on the www

The string after "?" in a URL is actually the "query string" and is
typically exposed as the QUERY_STRING environment variable in CGI. See
here for more specific details:

http://www.w3.org/CGI/
http://cgi-spec.golux.com/

What the cgi module provides is some conveniences for automatically
decoding the query string - perhaps not *so* difficult, you might
think, even taking the decoding of encoded values into account (such
as things like "%20" that you find in URLs) - but the cgi module also
provides facilities to decode request parameters that are supplied in
the body of a request (such as those provided in POST requests), and
that can be a more difficult exercise.

Paul




More information about the Python-list mailing list