Python Exchange whole Layouts during callbacks

Hello i was wondering if it is possible to exchange whole Layouts during callbacks with the Assignment app.layout = MyLayout.

Here a short example of what i want to do:

import pandas as pd

app = Dash(name)

try:
connecting to a Server

except Exception as Ex:
Error_log = “Error: “, Ex

If Error_log is not None:

app.layout = Layout1 (Connecting Error Message Layout)

elif Error_log is None:

df = pd.read_csv(path)

if len(df) < 5:

  app.layout = Layout2 (Not Enough Data Layout)

elif len(df) > 5:
app.Layout3 = Layout3 (Web Layout if everything works out)

Different callbacks to activate other Layouts, in case something changes

@app.callback():
def callback1:
try to reconnect
df = pd.read_csv(path)
if len(df) < 5:

  app.layout = Layout2 (Not Enough Data Layout)

elif len(df) > 5:
app.Layout3 = Layout3 (Web Layout if everything works out)

Hi,

One approach is to have a very simple layout like app.layout=html.Div(id="layout") and return the children of “layout” as the callback output. This is basically how Multi-Page Applications work.