import dash_auth import dash_core_components as dcc import dash_html_components as html import plotly # Modify these variables with your own info APP_NAME = 'halcyon-dashboard' APP_URL = 'http://halcyon-dashboard.herokuapp.com/index.html' external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] app = dash.Dash(__name__, external_stylesheets=external_stylesheets) auth = dash_auth.PlotlyAuth( app, APP_NAME, 'private', APP_URL ) app.layout = html.Div([ html.H1('Welcome to the app'), html.H3('You are successfully authorized'), dcc.Dropdown( id='dropdown', options=[{'label': i, 'value': i} for i in ['A', 'B']], value='A' ), dcc.Graph(id='graph') ], className='container') @app.callback(
# pip install dash-auth==0.0.2 import dash import dash_auth import dash_html_components as html import dash_core_components as dcc import os import plotly os.environ['PLOTLY_USERNAME'] = '******' os.environ['PLOTLY_API_KEY'] = '9kCBELqYp54Dygjn7zhH' app = dash.Dash('auth') auth = dash_auth.PlotlyAuth( app, 'Dash Authentication Sample App', 'private', 'http://localhost:8050' ) server = app.server app.layout = html.Div([ html.H1('Welcome to the app'), html.H3('You are successfully authorized'), dcc.Dropdown( id='dropdown', options=[{'label': i, 'value': i} for i in ['A', 'B']], value='A' ), dcc.Graph(id='graph') ], className="container")
raise Exception( 'Please enter the name of your dash app inside config.py') app.config.requests_pathname_prefix = '/{}/'.format( config.DASH_APP_NAME) if config.PATH_BASED_ROUTING: APP_URL = '{}/{}'.format( config.PLOTLY_DASH_DOMAIN.strip('/'), config.DASH_APP_NAME, ) else: APP_URL = '{}://{}.{}'.format( config.PLOTLY_DASH_DOMAIN.split('://')[0], config.DASH_APP_NAME, config.PLOTLY_DASH_DOMAIN.split('://')[1].strip('/')) dash_auth.PlotlyAuth(app, config.DASH_APP_NAME, config.DASH_APP_PRIVACY, APP_URL) # Expose the server variable server = app.server # Serve JS and CSS files locally instead of from global CDN # app.scripts.config.serve_locally = True # app.css.config.serve_locally = True # Standard Dash app code below app.layout = html.Div([ html.H2('Hello World'), dcc.Dropdown(id='dropdown', options=[{ 'label': i, 'value': i