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


Python Request.get_data方法代码示例

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


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

示例1: application

# 需要导入模块: from werkzeug.wrappers import Request [as 别名]
# 或者: from werkzeug.wrappers.Request import get_data [as 别名]
    def application(environ, start_response):
        # The WSGI server puts content length and type in the environment
        # even when not provided with the request. Drop them if they are empty.
        if environ.get('CONTENT_LENGTH') == '':
            del environ['CONTENT_LENGTH']
        if environ.get('CONTENT_TYPE') == '':
            del environ['CONTENT_TYPE']

        wrequest = WerkzeugRequest(environ)
        data = wrequest.get_data()
        request = Request(
            method=wrequest.method,
            url=wrequest.url,
            headers=wrequest.headers,
            data=data,
        )
        prepared = request.prepare()

        stream = streams.build_output_stream(
            args, env, prepared, response=None,
            output_options=args.output_options)
        streams.write_stream(stream, env.stdout, env.stdout_isatty)

        # When there is data in the request, give the next one breathing room.
        if data:
            print("\n", file=env.stdout)

        # Make dreams come true.
        response = Response(headers={'Server': server})
        return response(environ, start_response)
开发者ID:mblayman,项目名称:httpony,代码行数:32,代码来源:application.py

示例2: _request_signature

# 需要导入模块: from werkzeug.wrappers import Request [as 别名]
# 或者: from werkzeug.wrappers.Request import get_data [as 别名]
 def _request_signature(self, environ, digest):
     h = hmac.new(
         self._secret_key.encode('utf8'),
         self.string_to_sign(environ).encode('utf8'),
         digest,
     )
     request = Request(environ)
     if 'wsgi.input' in environ:
         h.update(request.get_data())
     return digest().name + ' ' + base64.b64encode(h.digest()).decode('utf8')
开发者ID:18F,项目名称:hmac_authentication_py,代码行数:12,代码来源:hmacauth.py

示例3: __call__

# 需要导入模块: from werkzeug.wrappers import Request [as 别名]
# 或者: from werkzeug.wrappers.Request import get_data [as 别名]
 def __call__(self, environ, start_response):
     request = Request(environ)
     try:
         name, args, kwargs = loads(request.get_data(cache=True))
         debug('calling function: "%s"', name)
         result = self.rpc()(name, *args, **kwargs)
         execution_error = None
     except Exception, e:
         execution_error = ErrorMessage.from_exception(e, address=request.host_url)
         result = None
         error('error: %s, traceback: \n%s', e, traceback.format_exc())
开发者ID:cosminbasca,项目名称:asyncrpc,代码行数:13,代码来源:wsgi.py

示例4: app

# 需要导入模块: from werkzeug.wrappers import Request [as 别名]
# 或者: from werkzeug.wrappers.Request import get_data [as 别名]
def app(request: Request):
    if request.path != '/':
        return Response(
            json.dumps({
                'error': 'not-found',
                'message': "page not found; there's only one path: /"
            }),
            status=404
        )
    elif request.method.upper() != 'POST':
        return Response(
            json.dumps({
                'error': 'method-not-allowed',
                'message': 'only POST method is allowed'
            }),
            status=405
        )
    elif request.mimetype not in {'text/html', 'application/xhtml+xml'}:
        return Response(
            json.dumps({
                'error': 'bad-request',
                'message': 'content has to be HTML'
            }),
            status=400
        )
    matched = request.accept_mimetypes.best_match(SUPPORTED_TYPES.keys())
    if not matched:
        return Response(
            json.dumps({
                'error': 'not-acceptable',
                'message': 'unsupported type; the list of supported '
                           'types: ' + ', '.join(SUPPORTED_TYPES)
            }),
            status=406
        )
    html = HTML(string=request.get_data(as_text=True))
    pdf_buffer = io.BytesIO()
    SUPPORTED_TYPES[matched](html, pdf_buffer)
    pdf_buffer.seek(0)
    return Response(pdf_buffer, mimetype=matched)
开发者ID:AiOO,项目名称:html2pdf-server,代码行数:42,代码来源:html2pdfd.py


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