This is My dash multi pages structure :
app.py :
app = dash.Dash(name, suppress_callback_exceptions=True,
# use bootsrap
external_stylesheets=[dbc.themes.LITERA , FONT_AWESOME],# different this change your code
# for mobile
meta_tags=[{'name': 'viewport',
'content': 'width=device-width, initial-scale=1.0'}]
)
index.py
sidebar = html.Div(
[
html.Div(Lottie(options=options, width="67%", height="67%", url=logo)),
html.Hr(),
html.P(
"A simple sidebar layout with navigation links", className="lead"
),
dbc.Nav(
[
dbc.NavLink("Home", href="/", active="exact"),
dbc.NavLink("Individus", href="/apps/individus", active="exact"),
dbc.NavLink("Agees", href="/apps/agees", active="exact"),
],
vertical=True,
pills=True,
),
],
style=SIDEBAR_STYLE
)
content = html.Div(id="page-content", style=CONTENT_STYLE )
footer = html.Div("ABC Š 2022", style=FOOTER_STYLE )
app.layout = html.Div([
dcc.Location(id="url-login"),
dcc.Store(id="login-status", storage_type="session"),
html.Div(id="user-status-header")
, dcc.Location(id="url"),sidebar , content , footer ])
@app.callback(Output("page-content", "children"), [Input("url", "pathname")])
def render_page_content(pathname):
if pathname == "/":
return home.layout
elif pathname == "/apps/individus":
return individus.layout
elif pathname == "/apps/agees":
return agees.layout
else :
return html.Div([
html.H1("404: Not found", className="text-danger"),
html.Hr(),
html.P(f"The pathname {pathname} was not recognised...") ])
if __name__ == "__main__":
app.env = "development"
app.run_server(debug=True)
I want to add a login page to my dash app with flask , But I didnât know how to to this ?