views:

85

answers:

1

I want my python script to simultaneously accept POST variables and query string variables from the web address.

The script has code :

form = cgi.FieldStorage()
print form

However, this only captures the post variables and no query variables from the web address. Is there a way to do this?

Thanks,

Ali

+1  A: 

cgi.parse_qsl (in any Python 2.*; urlparse.parse_qsl in 2.6 or better) take a query string and return a list of name, value pairs. Use os.environ['QUERY_STRING'] to get the query string part of the URL your CGI script was reached at (everything after the ? in the URL, if any).

Alex Martelli