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')
def __call__(self, *args, **kwargs): abort_code = getattr( self, ABORT_ATTRIBUTE_NAME, None, ) if abort_code: _abort(abort_code) return self.make_response()
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})
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)
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)