示例#1
0
    def resumable():
        resumableIdentfier = _request.args.get('resumableIdentifier', type=str)
        resumableFilename = _request.args.get('resumableFilename', type=str)
        resumableChunkNumber = _request.args.get('resumableChunkNumber',
                                                 type=int)

        if not (resumableIdentfier and resumableFilename
                and resumableChunkNumber):
            # Parameters are missing or invalid
            _abort(500, 'Parameter error')

        # chunk folder path based on the parameters
        temp_dir = _os.path.join(temp_base, resumableIdentfier)

        # chunk path based on the parameters
        chunk_file = _os.path.join(
            temp_dir, get_chunk_name(resumableFilename, resumableChunkNumber))
        server.logger.debug('Getting chunk: %s', chunk_file)

        if _os.path.isfile(chunk_file):
            # Let resumable.js know this chunk already exists
            return 'OK'
        else:
            # Let resumable.js know this chunk does not exists
            # and needs to be uploaded
            _abort(404, 'Not found')
示例#2
0
    def __call__(self, *args, **kwargs):
        abort_code = getattr(
            self, ABORT_ATTRIBUTE_NAME, None,
        )

        if abort_code:
            _abort(abort_code)

        return self.make_response()
示例#3
0
def abort(status_code, message=None):
    """
    Enhanced ``abort()`` function which allows
    passing a simple error message.

    :param int status_code: the (error) status code
    :param str message: the (error) message
    """
    if message is None:
        message = "bad request"
    _abort(status_code, {"message": message})
示例#4
0
        def wrapper(*args, **kwargs) -> object:
            """参数包装器"""

            # 获取地址
            address = ipaddress.ip_address(_request.remote_addr)

            # 判断地址
            for network in networks:
                if address in network:
                    return function(*args, **kwargs)

            return _abort(403)
示例#5
0
def abort(message='An error occurred while processing your request', status=400, **data):
    data.update(status=status, message=message)
    resp = Response(json.dumps(data), content_type='application/json', status=status)
    _abort(resp)