Skip to main content

Generate boilerplate code for plotly Dash apps

Project description

create-dash-app


PyPI version License Build status

create-dash-app is a utility for creating a boilerplate Dash applications.

Why?

I made this primarily because I wanted an easy way to initialize a Dash application that logically separates code.

If you're new to Dash, the docs lead you down a design path of single file apps. This may be fine for their simple examples, but in the real world your application will quickly grow untenable as you build out more complex views.

I personally have run into this issue at least 2 times, and because I find refactoring to be a tedious chore, I decided to build a tool to address it. I even added some other features because I'm just such a nice guy.

Installing

Installation is simple with pip or your preferred package manager.

python -m pip install create-dash-app

To test the installation

python -m create_dash_app -h

Running

Running is also simple and can be done in one of two ways:

To use the executable:

create-dash-app

To run via python:

python -m create_dash_app

Structure

The main point of this package is to lay out your new app in a helpful structure, so let's take a moment to review this snazzy structure.

dash_app
├── __init__.py
├── app.py
├── assets
│   ├── dash.min.css
│   └── dbc.min.css
├── callbacks
│   ├── __init__.py
│   └── index.py
├── components
│   ├── __init__.py
│   └── index.py
├── server.py
└── wsgi.py

This layout should intuitively make sense if you are familiar with Dash, but if you are a newbie or you can't read my mind here is a file/folder level breakdown.

Root Level Files

app.py

Your entrypoint to the Flask development server:

python dash_app/app.py

Typically, you won't have to touch this file.


server.py

Dash app configuration and cache configuration live here.


wsgi.py

A clean entrypoint if you run dash via a wsgi server (which you should be doing). For example:

gunicorn dash_app.wsgi -b :8050

Assets

This folder contains any static assets (CSS, images, JavaScript, etc.) you want to host. Read this page for more information on the assets folder.

Callbacks

All of your callback definitions should live here. callbacks.index is imported by app.py to prevent any circular dependency issues with the Dash object. It also means that if you create additional callback files, you only have to import them in callbacks.index and they will flow through to your app.

Components

All of your components definitions should live here, with components.index.Layout acting as the highest level Div. Similar to the callback directory, if you create additional component files you only need to make their components children of Layout.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

create-dash-app-0.1.2.tar.gz (11.5 kB view hashes)

Uploaded Source

Built Distribution

create_dash_app-0.1.2-py3-none-any.whl (13.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page