Skip to main content

Dash Single Page Application (SPA) Framework

Project description

dash-spa

Dash/SPA is a minimal template and component suite that allows you to build complex Dash based multi-page applications with ease. The demo application includes several well known Dash demos that have been pasted into the SPA framework to show how easy it is to transition to SPA.

Dash/SPA supports Flask style Blueprints and route decorators:

Code Snippet

pip install dash-spa
import dash_html_components as html
from dash_spa import Blueprint

greetings = Blueprint('greetings')

@greetings.route('/hello')
def hello():
    return html.H2('Dash/SPA says HELLO!')

@greetings.route('/goodby')
def goodby():
    return html.H2('Dash/SPA says GOODBY!')

...

app.register_blueprint(greetings, url_prefix='/test/greetings')

Dash/SPA manages component IDs using blueprint/route based namespaces. This greatly reduces Dash component ID conflicts. A component ID is only defined once when the component is created. It is then used by reference in associated Dash callbacks:

    user_name = spa.Input(id='user', placeholder="Enter name")
    password = spa.PasswordInput("Password", name='password', id='password', placeholder="Enter password")

    btn = spa.Button('Enter', id='enter', disabled=True)

    @app.callback(btn.output.disabled, [user_name.input.value, password.input.value])
    def _cb_enter(user_name, password):
        return not db_validate_user(user_name, password)

Dash/SPA includes an optional NAVBAR, configured by a simple dictionary:

NAV_BAR_ITEMS = {
    'brand' : spa.NavbarBrand('Dash/SPA','/'),
    'left' : [
        spa.NavbarLink('Global Warming','/demo/warming'),
        spa.NavbarLink('State Solar', '/demo/solar'),
        spa.NavbarLink('Ticker', '/demo/ticker?tickers=COKE'),
        spa.NavbarLink('Profile', '/user/profile'),
        spa.NavbarLink('Admin', '/admin/users'),
    ],
    'right': [
        AdminNavbarComponent()
    ],

    'footer': spa.Footer('SPA/Examples'),
}

Dash/SPA Allows easy creation of interactive forms

        email = spa.Input('Email', name='email', type='email', placeholder="Enter email")
        password = spa.PasswordInput("Password", name='password', placeholder="Enter password")
        button = button = spa.Button('Sign In', type='submit')

        form = spa.Form([
            email,
            password,
            button,
        ], title='Sign In'),


        @spa.callback(form.output.children, [form.input.form_data])
        def _form_submit(values):
            print(values)
            return spa.NOUPDATE

Admin Blueprint

Dash/SPA Includes an optional admin blueprint that supports user registration, email authentication and login. This is provided as a demonstrator, careful consideration to the security implications should be undertaken before using it in a public website.

Views are provided that allow:

  • Register, name, email, password. Verification code send by email.

  • Enter the email verification code.

  • Normal user login.

  • Reset forgotten password, Password reset code sent by email.

  • Enter password reset code.

  • Enter new password, confirm new password.

  • Login using new password.

  • User admin table with Add, Edit and Delete. Accessible only when signed in with admin rights.

Documentation

Head over to the README for more details.

Contributing

The source code for dash-spa is available on GitHub. If you find a bug or something is unclear, we encourage you to raise an issue. We also welcome contributions, to contribute, fork the repository and open a pull request.

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

dash-spa-0.0.5.tar.gz (26.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dash_spa-0.0.5-py3-none-any.whl (31.4 kB view details)

Uploaded Python 3

File details

Details for the file dash-spa-0.0.5.tar.gz.

File metadata

  • Download URL: dash-spa-0.0.5.tar.gz
  • Upload date:
  • Size: 26.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for dash-spa-0.0.5.tar.gz
Algorithm Hash digest
SHA256 8246b0e3827a355532d7a6d46fb03c000dab636f7fba72f4745b98c1653723a8
MD5 51e52fde0733b6c5da4152c95133e5c1
BLAKE2b-256 72ba9e7b4c13bb5bbd26638e6e376bb0b3ae28536d5e61aa47db55fbb887c008

See more details on using hashes here.

File details

Details for the file dash_spa-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: dash_spa-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 31.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

File hashes

Hashes for dash_spa-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 64da68624d7b2f121798b79d6993d911996bb241b5f9b1b3d0d777c72c606ddc
MD5 a4fb918b041838c5e3d096b7a3bfe826
BLAKE2b-256 5fe31f9df464b8b242b236048ad4cfdffd32adb0c91923381917239deabc5d44

See more details on using hashes here.

Supported by

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