Python CGI: how to retrieve variables passed by URL

Heiko Wundram heikowu at ceosg.de
Fri Apr 23 04:49:22 EDT 2004


Am Freitag 23 April 2004 07:42 schrieb Sean Berry:
> print os.environ["QUERY_STRING"].split("=")[1]
>
> prints value if I use localhost/cgi-bin/script-name.cgi?variable=value and
> this will work... but is there a better way?

Start python, and type import cgi and then help(cgi). The cgi module should 
take care of what you need perfectly. If the docstrings aren't enough to get 
you started, go to www.python.org -> Documentation -> Global Module Index and 
check the documentation of the cgi module there.

HTH!

Heiko.




More information about the Python-list mailing list