Extremely long wait time when loading REST resource from angularjs Extremely long wait time when loading REST resource from angularjs flask flask

Extremely long wait time when loading REST resource from angularjs


We had the same problem and after some research the problem is related with the way Chrome uses connections and the default configuration of flask as mono threaded.

Added threaded=true when flask app is started solved the problem:

app.run(threaded=True)


I've run into the same issue (Angular frontend running in Chrome and Flask backend). After trying both Angular 1.2.x and 1.3.x, and a billion other permutations, the only "solution" I've found is to run the Flask backend with the Tornado web server (http://www.tornadoweb.org/en/stable/). Other WSGI containers may work, but this is the one I tested.

In your Flask application, paste the following:

from tornado.wsgi import WSGIContainerfrom tornado.httpserver import HTTPServerfrom tornado.ioloop import IOLoopif __name__ == '__main__':  http_server = HTTPServer(WSGIContainer(app))  http_server.listen(5000)  IOLoop.instance().start()

You can start your web server by typing:

python myserver.py


I am facing now very similar issue. My current solution (acceptable for my chef at this moment :) ), which unfortunately not remove all problems, is to set header:{ 'Content-Type': 'application/json' } to { 'Content-Type': 'text/plain' }. Now only first GET request is crazy slow, any next takes less than 500ms. I am using Restangular on the frontend and wsgiref.simple_server on the backend.