Dash multipage app with flask login

This is My dash multi pages structure :

flask

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 ?

did u find a solution ?

1 Like

hey @firas
unfortunatekly No

same problem here we hope that someone help us ! really there s a huge lack in documentation regarding ldap authentification

yes ! … I applied a lot of codes but it didn’t work for me

check this !
it didn’t work for me , but you can try it

i didn t get it how to move from login page to dashboard page !

if you have a code pls share it with me

myserver i think is the flask server like this server = Flask(name)

I think this is helpful … wish that can help you
I’ll try it and I’ll share my results