0

I've got a simple flask web-service that runs AI training and responds with a stream of HTML text. Code for learning looks like this:

@app.route('/learn')
def learn():
    def learn():
    yield 'Prepare for learning...<br>'

    # PREPARE MODEL

    yield 'Learning started...<br>'
    for i in range(100):

        # TRAIN A LITTLE

        yield i.__str__() + '%<br>'
return Response(learn(), mimetype='text/html')

It works, but it adds every new text to previous one and I would like to replace text with a new one. So, right now output is like this:

Prepare for learning...
Learning started...
0%  
1%
2%
3%
4%
5%
......

I would like to have:

0%

and then:

1%

and so on...
Is it possible? How to do this? Standard solutions that work with print, like \r at the end, doesn't work in this case.

0 Answers0