Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e780877

Browse files
committed
added parse_qs(query_string)
1 parent f54d967 commit e780877

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

Lib/cgi.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#
66
# modified by Steve Majewski <[email protected]> 12/5/94
77
#
8+
# now maintained as part of the Python distribution
89

910
# Several classes to parse the name/value pairs that are passed to
1011
# a server's CGI by GET, POST or PUT methods by a WWW FORM. This
@@ -42,11 +43,17 @@
4243

4344

4445
def parse():
46+
"""Parse the query passed in the environment or on stdin"""
4547
if environ['REQUEST_METHOD'] == 'POST':
4648
qs = sys.stdin.read(string.atoi(environ['CONTENT_LENGTH']))
4749
environ['QUERY_STRING'] = qs
4850
else:
4951
qs = environ['QUERY_STRING']
52+
return parse_qs(qs)
53+
54+
55+
def parse_qs(qs):
56+
"""Parse a query given as a string argument"""
5057
name_value_pairs = string.splitfields(qs, '&')
5158
dict = {}
5259
for name_value in name_value_pairs:

0 commit comments

Comments
 (0)