当前位置: 首页>>代码示例>>Python>>正文


Python cgi.parse方法代码示例

本文整理汇总了Python中cgi.parse方法的典型用法代码示例。如果您正苦于以下问题:Python cgi.parse方法的具体用法?Python cgi.parse怎么用?Python cgi.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cgi的用法示例。


在下文中一共展示了cgi.parse方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: pyro_app

# 需要导入模块: import cgi [as 别名]
# 或者: from cgi import parse [as 别名]
def pyro_app(environ, start_response):
    """
    The WSGI app function that is used to process the requests.
    You can stick this into a wsgi server of your choice, or use the main() method
    to use the default wsgiref server.
    """
    config.SERIALIZER = "json"     # we only talk json through the http proxy
    config.COMMTIMEOUT = pyro_app.comm_timeout
    method = environ.get("REQUEST_METHOD")
    path = environ.get('PATH_INFO', '').lstrip('/')
    if not path:
        return redirect(start_response, "/pyro/")
    if path.startswith("pyro/"):
        if method in ("GET", "POST"):
            parameters = singlyfy_parameters(cgi.parse(environ['wsgi.input'], environ))
            return process_pyro_request(environ, path[5:], parameters, start_response)
        else:
            return invalid_request(start_response)
    return not_found(start_response) 
开发者ID:irmen,项目名称:Pyro5,代码行数:21,代码来源:httpgateway.py

示例2: do_test

# 需要导入模块: import cgi [as 别名]
# 或者: from cgi import parse [as 别名]
def do_test(buf, method):
    env = {}
    if method == "GET":
        fp = None
        env['REQUEST_METHOD'] = 'GET'
        env['QUERY_STRING'] = buf
    elif method == "POST":
        fp = StringIO(buf)
        env['REQUEST_METHOD'] = 'POST'
        env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'
        env['CONTENT_LENGTH'] = str(len(buf))
    else:
        raise ValueError, "unknown method: %s" % method
    try:
        return cgi.parse(fp, env, strict_parsing=1)
    except StandardError, err:
        return ComparableException(err) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test_cgi.py

示例3: do_test

# 需要导入模块: import cgi [as 别名]
# 或者: from cgi import parse [as 别名]
def do_test(buf, method):
    env = {}
    if method == "GET":
        fp = None
        env['REQUEST_METHOD'] = 'GET'
        env['QUERY_STRING'] = buf
    elif method == "POST":
        fp = BytesIO(buf.encode('latin-1')) # FieldStorage expects bytes
        env['REQUEST_METHOD'] = 'POST'
        env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'
        env['CONTENT_LENGTH'] = str(len(buf))
    else:
        raise ValueError("unknown method: %s" % method)
    try:
        return cgi.parse(fp, env, strict_parsing=1)
    except Exception as err:
        return ComparableException(err) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:19,代码来源:test_cgi.py

示例4: do_POST

# 需要导入模块: import cgi [as 别名]
# 或者: from cgi import parse [as 别名]
def do_POST(self):
		length = self.headers.get('content-length')
		if not length:
			return self._bad_request()
		if hasattr(self.headers, 'get_content_type'):
			ctype = self.headers.get_content_type()
		elif self.headers.typeheader is None:
			ctype = self.headers.type
		else:
			ctype = self.headers.typeheader
		bare_ctype = ctype.split(";", 1)[0].strip()
		if bare_ctype in ("application/x-www-form-urlencoded", "multipart/form-data"):
			env = {"CONTENT_LENGTH": length,
			       "CONTENT_TYPE"  : ctype,
			       "REQUEST_METHOD": "POST"
			      }
			cgi_args = cgi.parse(self.rfile, environ=env, keep_blank_values=True)
		else:
			cgi_args = {None: [self.rfile.read(int(length))]}
		self.is_head = False
		self._do_req2(self.path, cgi_args) 
开发者ID:eBay,项目名称:accelerator,代码行数:23,代码来源:web.py

示例5: do_test

# 需要导入模块: import cgi [as 别名]
# 或者: from cgi import parse [as 别名]
def do_test(buf, method):
    env = {}
    if method == "GET":
        fp = None
        env['REQUEST_METHOD'] = 'GET'
        env['QUERY_STRING'] = buf
    elif method == "POST":
        fp = StringIO(buf)
        env['REQUEST_METHOD'] = 'POST'
        env['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'
        env['CONTENT_LENGTH'] = str(len(buf))
    else:
        raise ValueError, "unknown method: %s" % method
    try:
        return cgi.parse(fp, env, strict_parsing=1)
    except StandardError, err:
        return ComparableException(err)

# A list of test cases.  Each test case is a a two-tuple that contains
# a string with the query and a dictionary with the expected result. 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:22,代码来源:test_cgi.py

示例6: test_deprecated_parse_qs

# 需要导入模块: import cgi [as 别名]
# 或者: from cgi import parse [as 别名]
def test_deprecated_parse_qs(self):
        # this func is moved to urllib.parse, this is just a sanity check
        with check_warnings(('cgi.parse_qs is deprecated, use urllib.parse.'
                             'parse_qs instead', DeprecationWarning)):
            self.assertEqual({'a': ['A1'], 'B': ['B3'], 'b': ['B2']},
                             cgi.parse_qs('a=A1&b=B2&B=B3')) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:8,代码来源:test_cgi.py

示例7: test_deprecated_parse_qsl

# 需要导入模块: import cgi [as 别名]
# 或者: from cgi import parse [as 别名]
def test_deprecated_parse_qsl(self):
        # this func is moved to urllib.parse, this is just a sanity check
        with check_warnings(('cgi.parse_qsl is deprecated, use urllib.parse.'
                             'parse_qsl instead', DeprecationWarning)):
            self.assertEqual([('a', 'A1'), ('b', 'B2'), ('B', 'B3')],
                             cgi.parse_qsl('a=A1&b=B2&B=B3')) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:8,代码来源:test_cgi.py


注:本文中的cgi.parse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。