By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,400 Members | 903 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,400 IT Pros & Developers. It's quick & easy.

Python CGI: how to retrieve variables passed by URL

P: n/a
If I go to my cgi python script with
localhost/cgi-bin/script-name.cgi?variable=value

How do I gather this value?

Thanks in advance.
Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
This may help, but not sure if there is a better, built in way.

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?

"Sean Berry" <se********@cox.net> wrote in message
news:hU1ic.86730$U83.37750@fed1read03...
If I go to my cgi python script with
localhost/cgi-bin/script-name.cgi?variable=value

How do I gather this value?

Thanks in advance.

Jul 18 '05 #2

P: n/a
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.

Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.