swagger_stub.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:swagger-stub 作者: Trax-air 项目源码 文件源码
def get_parsed_body(request):
    """Get the body (json or formData) of the request parsed.

    Args:
        request: request object to get the body from.

    Returns:
        A dictionary of the body.

    Raises:
        ValueError: if it is neither a json or a formData
    """
    data = None
    if not request.parsed_body == '':
        try:
            data = json.loads(request.body.decode('utf-8'))
        except Exception:  # Decode formData
            data = dict(parse_qsl(request.body))

            if not data:  # Not a form data
                raise
    return data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号