I want to route a Dash app (which is in the separate module
dash_app.py) through my general flask app (which is in the module
In stand-alone mode the Dash app runs perfectly, but when I route it through the separate Flask app I get an “Error loading layout” on the Dash route.
This is what the modules structure-wise look like. First
def make_dash_app(server=None, url_base_pathname=None): _app = dash.Dash(__name__, server=server, url_base_pathname=url_base_pathname, assets_ignore='_.*') _app.layout = html.Div( ...lots of stuff using other functions in the module... ) return _app if __name__ == '__main__': make_dash_app().run_server(debug=True)
# The flask server app flask_app = flask.Flask(__name__) @flask_app.route('/hello') def hello_world(): return 'A static Hello!' # The Dash app and its route import dash_app _dash = dash_app.make_dash_app(server=flask_app, url_base_pathname='/dash/') @flask_app.route('/dash') def render_dash_app(): return flask.redirect('/dash/') if __name__ == '__main__': flask_app.run(debug=True)
I guess the problem is somehow related to the module separation, because when I merge both modules into one, it works. But that is not scalable when i want to add more Dash apps. How can I make it work with the module separation?