E
E
Emil Revencu2019-11-10 00:47:33
IIS
Emil Revencu, 2019-11-10 00:47:33

Why doesn't Flask streaming work on IIS?

I have code:

from flask import Flask, Response
from datetime import datetime
import time

app = Flask(__name__)

@app.route('/')
def first(): return 'ok'

@app.route('/stream')
def default():
    def generate():
        for i in range(0,10):
            yield datetime.now().strftime('%H:%M:%S')
            time.sleep(1)
    return Response(generate(), mimetype='text/html') #Пробовал и mimetype='text/event-stream'

if __name__ == '__main__':
  app.run(host='0.0.0.0', debug=True, port=5001)

When running in development mode " localhost:5001/stream " I get 10 responses every second.
That is, streaming works
If I do deploy on Windows IIS, then streaming does not work (I get the whole result after 10 seconds).
It can be seen that IIS somehow blocks yield - something else needs to be configured in IIS.
How to solve streaming Flask on Windows production mode?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question