@app.route('/file/{file}/downalod')
def file_download(file):
# some stuff with fetching from the database
def reader():
with open('path', 'rb') as file:
file.seek(offset)
left = length
while left > 0:
text = file.read(min(left, 1024))
left -= len(text)
yield text
return Response(reader())
Sample route: