Hi, I am a novice in dash. So I have such a problem when creating logout button.
Exception: DASH_LOGOUT_URL was not set in the environment.
where could I find examples.
thanks in advance
Hi, I am a novice in dash. So I have such a problem when creating logout button.
Exception: DASH_LOGOUT_URL was not set in the environment.
where could I find examples.
thanks in advance
No longer supported (https://dash.plotly.com/dash-core-components/logoutbutton)
thanks, could you give a toy example, how to create it, that is what parameters to give,
I am using this
html.Div(auth.create_logout_button(), className=‘col 2’, style={‘marginLeft’: 5})
From Dash Enterprise Auth Features | Dash for Python Documentation | Plotly,
The example below demonstrates how to use these callbacks. Note that in order to use
create_logout_button
locally you will have to set an environment variable calledDASH_LOGOUT_URL
. You can do this by running your code withDASH_LOGOUT_URL=plotly.com python app.py
.
Is this how you are running your app? it seems DASH_LOGOUT_URL
is the url the user is taken to upon logout…that’s just a guess as I have not used this dash_enterprise_auth
I changed the method as you suggested,
now I use the below code, but how to write the right a callback I dont know yet.
thanks a lot
import dash_html_components as html
from dash.dependencies import Input, Output, State
import dash_enterprise_auth as auth
import base64
from app import app
from apps import retail, service, home, login
image_filename = 'img//images.png'
encoded_image = base64.b64encode(open(image_filename , 'rb').read())
app.title = 'Retail'
app.layout = html.Div([
html.Nav(className = "nav nav-pills bg-light", children=[
html.Img(src='data:image/png;base64,{}'.format(encoded_image.decode()), className = 'logo_img', width="45", height="45"),
html.A('Home', className="nav-item nav-link btn", id = 'nav_app3', href='/apps/home'),
html.A('Retail', className="nav-item nav-link btn col 2", id = 'nav_app1', href='/apps/retail'),
html.A('Service Centers', className="nav-item nav-link btn col 2", id = 'nav_app2', href='/apps/service'),
html.A('Distribution Channels', className="nav-item nav-link btn col 2", id = 'nav_app5', href='/apps/retail'),
html.A('CallCenter', className="nav-item nav-link btn col 2", id = 'nav_app6', href='/apps/service'),
html.A('Portfolio', className="nav-item nav-link btn col 2", id = 'nav_app7', href='/apps/service'),
html.Button('Log Out', className="nav-item nav-link btn col 12", id = 'logout_btn', n_clicks = 0),
# html.Button('Submit', className="nav-item nav-link btn col 12", id='submit-val', n_clicks=0),
# html.Div(auth.create_logout_button(), className='col 2', style={'marginLeft': 5}),
]),
dcc.Location(id='url', refresh=False),
html.Div(id='page-content'),
])
@app.callback(Output('page-content', 'children'),
[Input('url', 'pathname'),
Input('logout_btn', 'n_clicks')])
def display_page(pathname, value):
if pathname == '/apps/retail':
return retail.layout
elif pathname == '/apps/service':
return service.layout
elif pathname == '/apps/home':
return home.layout
elif value:
return home.layout
else:
return ''
# @app.callback(Output('page-content', 'children'),
# [Input('nav_app4','n_clicks')])
# def logout(value):
# if value:
# return
if __name__ == '__main__':
app.run_server(debug=True)