✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Combining seperate Dash app with Flask app results in "Error loading layout"

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 flask_app.py).

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 dash_app.py:

def make_dash_app(server=None, url_base_pathname=None):
    _app = dash.Dash(__name__,

    _app.layout = html.Div(
        ...lots of stuff using other functions in the module...
    return _app

if __name__ == '__main__':

And flask_app.py:

# The flask server app
flask_app = flask.Flask(__name__)

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,

def render_dash_app():
    return flask.redirect('/dash/')

if __name__ == '__main__':

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?