-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

abcd wrote:
> i want to create a CGI script which simply prints out values given via
> the URL (such as when a GET is performed).
> 
> So if I have a script named, foo.cgi ....and I access it by going to:
> 
> http://www.somesite.com/cgi-bin/foo.cgi?name=john&age=90
> 
> I want foo.cgi to print out:
> name: john
> age: 90
> 
> 
> how do i get the values from the URL like that?
> 
> thanks

>>> from urlparse import urlparse
>>> dict([n for n in [i.split('=') for i in
urlparse('http://www.somesite.com/cgi-bin/foo.cgi?name=john&age=90')[4].split('&')]])
{'age': '90', 'name': 'john'}
>>>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFD94zrefZ4eWAXRGIRAlEhAJ49x7kaIe/VcU5DUbt8bv9tQCNrmQCfWOED
tmkTISLqzIKDz2c4mfR6+k8=
=OMOX
-----END PGP SIGNATURE-----
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to