decorators.py 文件源码

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

项目:heroku-python-boilerplate 作者: chavli 项目源码 文件源码
def validate_jpeg_binary(func):
    """ checks the mimetype and the binary data to ensure it's a JPEG """
    @wraps(func)
    def wrapper(*args, **kwargs):
        if request.content_type != "image/jpeg":
            return ErrorResponseJson("invalid content type: {}".format(request.content_type)).make_response()
        if imghdr.test_jpeg(request.data, None) != "jpeg":
            return ErrorResponseJson("invalid jpeg data").make_response()
        return func(*args, **kwargs)
    return wrapper
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号