I found this example on the Bottle docs re asynchronous responses.
Here is the code slightly modified:
from gevent import monkey; monkey.patch_all()
from time import sleep
from bottle import hook, response, route, run
@route('/stream')
def stream():
yield 'START'
sleep(3)
yield '\nPROGRESS 1'
sleep(3)
yield '\nPROGRESS 2'
sleep(3)
yield '\nPROGRESS 3'
sleep(3)
yield '\nEND'
run(host='0.0.0.0', port=8080, server='gevent')
calling this view from the browser works as explained in the docs:
If you run this script and point your browser to http://localhost:8080/stream, you should see START, MIDDLE, and END show up one by one (rather than waiting 8 seconds to see them all at once).
I was wondering how to handle this via Javascript in an AJAX request, specifically with JQuery, in order to display the messages in sequence.
ANy help about that?