2

Dash is a dashboard-related python library that is based on Flask. The default dash app will run a Flask server, which is as they stated, "not recommended for production environment". I have managed to find Twisted library which can do decent html handling. The problem is, I know how to use Twisted to host flask sites, but I do not know how to do the same for dash app. There is a nice library which integrates both flask and twisted together.
https://github.com/cravler/flask-twisted
To use it, one just need to use the following lines:

server = flask.Flask(__name__)
app = dash.Dash(__name__, server = server)
twisted = Twisted(server)
twisted.run(host='0.0.0.0',port=8050, debug=False)

Now, for learning purposes, I am trying to recreate the same functionality without flask-twisted. I tried my best to follow the source code in the module but still cannot recreate the same result. The page http://127.0.0.1:8082/my_flask/ is stuck at "Loading...". What did I do wrong?

if __name__ == '__main__':
    resource = WSGIResource(reactor, reactor.getThreadPool(), server)
    site = Site(WSGIRootResource(resource, {}))
    server.run
    root = Resource()
    root.putChild(b'my_flask', site)
    reactor.listenTCP(8082, Site(root))
    reactor.run()
tonywang
  • 181
  • 2
  • 13

0 Answers0