Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

dash authentication

import dash
import dash_auth
import dash_core_components as dcc
import dash_html_components as html
import plotly

# Keep this out of source code repository - save in a file or a database
VALID_USERNAME_PASSWORD_PAIRS = {
    'hello': 'world'
}

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
auth = dash_auth.BasicAuth(
    app,
    VALID_USERNAME_PASSWORD_PAIRS
)

app.layout = html.Div([
    html.H1('Welcome to the app'),
    html.H3('You are successfully authorized'),
    dcc.Dropdown(['A', 'B'], 'A', id='dropdown'),
    dcc.Graph(id='graph')
], className='container')

@app.callback(
    dash.dependencies.Output('graph', 'figure'),
    [dash.dependencies.Input('dropdown', 'value')])
def update_graph(dropdown_value):
    return {
        'layout': {
            'title': 'Graph of {}'.format(dropdown_value),
            'margin': {
                'l': 20,
                'b': 20,
                'r': 10,
                't': 60
            }
        },
        'data': [{'x': [1, 2, 3], 'y': [4, 1, 2]}]
    }

if __name__ == '__main__':
    app.run_server(debug=True)
Comment

PREVIOUS NEXT
Code Example
Python :: __slots__ python example 
Python :: change creation date filesystem py 
Python :: import csv 
Python :: numpy shape 
Python :: django form action 
Python :: python not equal to 
Python :: if in one line python 
Python :: python class set dict method 
Python :: pyhton apend to list 
Python :: capitalise texts 
Python :: all combinations 
Python :: python max counts 
Python :: Fastest way to Convert Integers to Strings in Pandas DataFrame 
Python :: authentication serializer drf 
Python :: python np.sum 
Python :: python change label text 
Python :: pandas show all dataframe method 
Python :: rotate array in python 
Python :: whitelist the ip address django 
Python :: how to use a class in python 
Python :: np array size 
Python :: Python Generators with a Loop 
Python :: find item in list 
Python :: flask add_url_rule 
Python :: python create unreadable save file 
Python :: index start from 1 pandas 
Python :: protected vs private python 
Python :: ValueError: Graph disconnected: cannot obtain value for tensor Tensor("input_3_1:0", shape=(None, None, 71), dtype=float32) at layer "input_3". The following previous layers were accessed without issue: [] 
Python :: queue peek python 
Python :: define event on socketio python 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =