, ftp.upload() , . , , , , .
import threading, Queue
@app.route('/section')
def section():
q = Queue.Queue()
def callback(chunk):
q.put(len(chunk))
t = threading.Thread(target=lambda: ftp.upload(source, target, "b", callback) or q.put(None))
t.setDaemon(True)
t.start()
def generate():
while 1:
l = q.get()
if l is None:
return
yield unicode(l) + '\n'
return Response(generate())