CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-dash

Python web application framework for building reactive analytical web apps without JavaScript

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

core-application.mddocs/

Core Application

The Dash class is the central application instance that manages server configuration, component layout, callback registration, and application lifecycle. It provides the foundation for building reactive web applications with Python.

Capabilities

Application Initialization

Creates and configures a Dash application with server integration, asset management, and plugin support.

class Dash:
    def __init__(
        self,
        name: str = None,
        server: Any = None,
        assets_folder: str = 'assets',
        pages_folder: str = 'pages',
        use_pages: bool = None,
        assets_url_path: str = '/assets/',
        assets_ignore: str = '',
        external_scripts: List[Union[str, Dict]] = None,
        external_stylesheets: List[Union[str, Dict]] = None,
        suppress_callback_exceptions: bool = None,
        prevent_initial_callbacks: bool = None,
        show_undo_redo: bool = False,
        plugins: List = None,
        title: str = 'Dash',
        update_title: str = 'Updating...',
        meta_tags: List[Dict[str, str]] = None,
        index_string: str = None,
        compress: bool = None,
        **kwargs
    ):
        """
        Initialize a Dash application.
        
        Parameters:
        - name: Application name for Flask (typically __name__)
        - server: Existing Flask server instance
        - assets_folder: Directory for static assets
        - pages_folder: Directory for page modules (multi-page apps)
        - use_pages: Enable automatic page discovery
        - external_scripts: External JavaScript resources
        - external_stylesheets: External CSS resources
        - suppress_callback_exceptions: Allow callbacks for components not in layout
        - prevent_initial_callbacks: Prevent callbacks on initial load
        - plugins: List of Dash plugins
        - title: Browser window title
        - meta_tags: HTML meta tags for SEO
        """

Layout Management

Defines the application's user interface through a hierarchical component tree.

@property
def layout(self) -> LayoutType:
    """Get the application layout."""

@layout.setter  
def layout(self, value: LayoutType):
    """Set the application layout."""

def serve_layout(self) -> LayoutType:
    """Serve dynamic layout (called on each page load)."""

Server Operations

Controls application server lifecycle including development and production modes.

def run(
    self,
    host: str = '127.0.0.1',
    port: int = 8050,
    proxy: str = None,
    debug: bool = None,
    dev_tools_ui: bool = None,
    dev_tools_props_check: bool = None,
    dev_tools_serve_dev_bundles: bool = None,
    dev_tools_hot_reload: bool = None,
    dev_tools_hot_reload_interval: int = None,
    dev_tools_hot_reload_watch_interval: int = None,
    dev_tools_hot_reload_max_retry: int = None,
    dev_tools_silence_routes_logging: bool = None,
    dev_tools_prune_errors: bool = None,
    **flask_run_options
):
    """
    Run the Dash application server.
    
    Parameters:
    - host: Server host address
    - port: Server port number  
    - debug: Enable debug mode with hot reloading
    - dev_tools_ui: Show dev tools UI
    - dev_tools_hot_reload: Enable hot reloading
    """

def run_server(self, *args, **kwargs):
    """Alias for run() method."""

Callback Registration

Registers reactive callback functions that respond to component interactions.

def callback(
    self,
    output: Union[Output, List[Output]],
    inputs: Union[Input, List[Input]] = None,
    state: Union[State, List[State]] = None,
    prevent_initial_call: bool = None,
    background: bool = None,
    manager: Any = None,
    **kwargs
) -> Callable:
    """
    Decorator for registering callback functions.
    
    Parameters:
    - output: Output dependencies (what gets updated)
    - inputs: Input dependencies (what triggers the callback) 
    - state: State dependencies (additional values without triggering)
    - prevent_initial_call: Prevent callback on initial load
    - background: Run callback in background thread
    """

def clientside_callback(
    self,
    clientside_function: Union[ClientsideFunction, str],
    output: Union[Output, List[Output]],
    inputs: Union[Input, List[Input]] = None,
    state: Union[State, List[State]] = None,
    prevent_initial_call: bool = None,
    **kwargs
):
    """
    Register JavaScript callback for client-side execution.
    
    Parameters:
    - clientside_function: JavaScript function reference
    - output: Output dependencies
    - inputs: Input dependencies
    - state: State dependencies
    """

Configuration Properties

Application-level configuration and metadata management.

@property
def config(self) -> AttributeDict:
    """Get application configuration."""

@property
def scripts(self) -> Scripts:
    """Get JavaScript resources."""

@property  
def css(self) -> Css:
    """Get CSS resources."""

@property
def index_string(self) -> str:
    """Get HTML index template."""

@index_string.setter
def index_string(self, value: str):
    """Set HTML index template."""

@property
def title(self) -> str:
    """Get application title."""

@title.setter
def title(self, value: str):
    """Set application title."""

Asset and Resource Management

Handles static assets, external resources, and URL generation.

def get_asset_url(self, path: str) -> str:
    """Generate URL for asset file."""

def get_relative_path(self, path: str) -> str:
    """Get relative path from current request."""

def strip_relative_path(self, path: str) -> str:
    """Remove relative path prefix."""

Usage Examples

Basic Application

from dash import Dash, html

app = Dash(__name__)

app.layout = html.Div([
    html.H1("My Dash App"),
    html.P("Hello World!")
])

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

Application with External Resources

from dash import Dash, html

external_stylesheets = [
    'https://codepen.io/chriddyp/pen/bWLwgP.css'
]

external_scripts = [
    'https://code.jquery.com/jquery-3.6.0.min.js'
]

app = Dash(
    __name__,
    external_stylesheets=external_stylesheets,
    external_scripts=external_scripts,
    title="My Custom App"
)

app.layout = html.Div("Content")
app.run(debug=True)

Custom Server Integration

import flask
from dash import Dash, html

server = flask.Flask(__name__)

@server.route('/api/data')
def serve_data():
    return {'message': 'Hello from Flask'}

app = Dash(__name__, server=server)
app.layout = html.Div("Dash with custom Flask routes")

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

Types

LayoutType = Union[Component, List, Dict, str, int, float]
ServerType = Any  # Flask server instance
AssetList = List[Union[str, Dict[str, str]]]
MetaTagList = List[Dict[str, str]]
PluginList = List[Any]
AttributeDict = Dict[str, Any]

Install with Tessl CLI

npx tessl i tessl/pypi-dash

docs

asset-management.md

background-callbacks.md

callback-system.md

component-libraries.md

core-application.md

index.md

multi-page-apps.md

special-values.md

tile.json