s

Setting up a Dash app



Installing and running Dash

  1. Installation

pip install dash will install the three component libraries that make up the core of Dash: dash_html_components, dash_core_components, dash_table, as well as the plotly graphing library.

  • pip install jupyter-dash if using Jupyter Notebook or Jupter Lab as the development environment.

  • pip install dash --upgrade

Dash Bootstrap Components

  • dash-bootstrap-components is a library of Bootstrap components for Plotly Dash, that makes it easier to build consistently styled apps with complex, responsive layouts

Using a virtual environment:

Create and activate a Python virtual environment. Then go to the folder that is created and install the required packages.

python3 -m venv dash_projects
source dash_projects/bin/activate
  1. Dash Layout Dash apps are composed of two parts. The layout is the first part and describes what the application looks like. Dash provides Python classes for all the visual components of the application.

Create a file named app.py then run the app with python app.py.

# inport packages
import dash
import dash_core_components as dcc
import dash_html_components as html
import dash_bootstrap_components as dbc
import plotly.express as px
import pandas as pd

# create / instantiate the app
app = dash.Dash(__name__)

# create the app layout

app.layout = html.Div([
    html.H1(children='Weather App),

    html.Div(children= '''
    Dash: A web application for Python
    '''
    )
])

# run the app

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

Creating_app screenshot

Tech used:
  • Python
  • HTML