How to Create a Simple Dash App:
python
1from dash import Dash, html
2
3app = Dash(__name__)
4
5app.layout = html.Div('My Dashboard')
6
7if __name__ == '__main__':
8 app.run(debug=True)How to Create a Simple Dash App in a Jupyter Notebook with VS Code:
- jupyter-dash allows you to run Dash apps in different modes using a Jupyter Notebook.
1%pip install dash
2%pip install jupyter-dashpython
1from dash import Dash, html, dcc, jupyter_dash
2import pandas as pd
3import plotly.express as px
4
5jupyter_dash.default_mode="tab" # New browser tab
6#jupyter_dash.default_mode="external" # New browser window
7#jupyter_dash.default_mode="inline" # Inside the notebook
8
9app = Dash(__name__)
10
11app.layout = html.Div('My Dashboard')
12
13if __name__ == '__main__':
14 app.run(debug=True)How to Create a Simple Dash App in a Jupyter Notebook with Colab:
- Colab does not allow you to display a Dash app natively outside of a notebook.
1%pip install dashpython
1from dash import Dash, html, dcc
2import pandas as pd
3import plotly.express as px
4from google.colab import output # Shows the app in Colab
5
6app = Dash(__name__)
7
8app.layout = html.Div('My Dashboard')
9
10if __name__ == '__main__':
11 output.serve_kernel_port_as_iframe(port=8050)
12 app.run(port=8050) # Must run inside a notebook in Colab