0% found this document useful (0 votes)
80 views3 pages

A Minimal Dash App: Python

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views3 pages

A Minimal Dash App: Python

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

4/11/23, 1:07 PM A Minimal Dash App | Dash for Python Documentation | Plotly

Star 18,468

Python

Dash Python > A Minimal Dash App

A Minimal Dash App


A minimal Dash app will typically look like this:

from dash import Dash, html, dcc, callback, Output, Input


import plotly.express as px
import pandas as pd

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)

Title of Dash App


Canada
×

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

1950 1960 1970 1980 19

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.

Dash is running on http://127.0.0.1:8050/

* Serving Flask app 'app' (lazy loading)


* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: on
* Running on http://127.0.0.1:8050 (Press CTRL+C to quit)

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.

Learn More | Pricing | Dash Enterprise Demo | Dash Enterprise Overview

Dash Python > A Minimal Dash App

Products Pricing About Us Support Join our mailing

Dash Enterprise Pricing Careers Community Support list

Consulting and Training Resources Graphing Documentation


Sign up to stay in the
Blog
loop with all things Plotly
— from Dash Club to
product updates,
webinars, and more!

https://dash.plotly.com/minimal-app 2/3
4/11/23, 1:07 PM A Minimal Dash App | Dash for Python Documentation | Plotly

SUBSCRIBE

Copyright © 2023 Plotly. All rights reserved. Privacy Policy

https://dash.plotly.com/minimal-app 3/3

You might also like