summaryrefslogtreecommitdiffstats
path: root/Lib/cgi.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-08-07 20:12:09 (GMT)
committerGuido van Rossum <guido@python.org>1995-08-07 20:12:09 (GMT)
commite7808778d6200ad94fdcae1e797262f5a78048ee (patch)
treefee438b56cce41dd973c78922975d02a0c557aaa /Lib/cgi.py
parentf54d967fec5d3287a33b965316513a7250fa8de6 (diff)
downloadcpython-e7808778d6200ad94fdcae1e797262f5a78048ee.zip
cpython-e7808778d6200ad94fdcae1e797262f5a78048ee.tar.gz
cpython-e7808778d6200ad94fdcae1e797262f5a78048ee.tar.bz2
added parse_qs(query_string)
Diffstat (limited to 'Lib/cgi.py')
-rwxr-xr-xLib/cgi.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/cgi.py b/Lib/cgi.py
index 3862cb5..f146dc9 100755
--- a/Lib/cgi.py
+++ b/Lib/cgi.py
@@ -5,6 +5,7 @@
#
# modified by Steve Majewski <sdm7g@Virginia.EDU> 12/5/94
#
+# now maintained as part of the Python distribution
# Several classes to parse the name/value pairs that are passed to
# a server's CGI by GET, POST or PUT methods by a WWW FORM. This
@@ -42,11 +43,17 @@ from os import environ
def parse():
+ """Parse the query passed in the environment or on stdin"""
if environ['REQUEST_METHOD'] == 'POST':
qs = sys.stdin.read(string.atoi(environ['CONTENT_LENGTH']))
environ['QUERY_STRING'] = qs
else:
qs = environ['QUERY_STRING']
+ return parse_qs(qs)
+
+
+def parse_qs(qs):
+ """Parse a query given as a string argument"""
name_value_pairs = string.splitfields(qs, '&')
dict = {}
for name_value in name_value_pairs: