A Minimal Dash App: Python
A Minimal Dash App: Python
Star 18,468
Python
df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/gapmin
app = Dash(__name__)
app.layout = html.Div([
html.H1(children='Title of Dash App', style={'textAlign':'center'}),
dcc.Dropdown(df.country.unique(), 'Canada', id='dropdown-selection'),
dcc.Graph(id='graph-content')
])
@callback(
Output('graph-content', 'figure'),
Input('dropdown-selection', 'value')
)
def update_graph(value):
dff = df[df.country==value]
return px.line(dff, x='year', y='pop')
if __name__ == '__main__':
app.run_server(debug=True)
30M
https://dash.plotly.com/minimal-app 1/3
4/11/23, 1:07 PM A Minimal Dash App | Dash for Python Documentation | Plotly
25M
pop
20M
15M
year
To run the app, copy the above code into a new file named app.py and type into your terminal
the command python app.py . Then, go to the http link.
The next section will cover the main elements of a Dash app. Dash in 20 minutes tutorial!
These docs are a Dash app running on Dash Enterprise on Azure Kubernetes Service.
Write, deploy, and scale Dash apps on a Dash Enterprise Kubernetes cluster.
https://dash.plotly.com/minimal-app 2/3
4/11/23, 1:07 PM A Minimal Dash App | Dash for Python Documentation | Plotly
SUBSCRIBE
https://dash.plotly.com/minimal-app 3/3