Directory format for bokeh apps and templates

Bokeh apps can also be defined with a directory format. This format allows the use of additional modules, data, templates, themes and other functions. The directory should contain a main.py file, which is the entry point for the app, but other parts can be included:

.
└── myapp
    ├── __init__.py
    ├── main.py
    ├── request_handler.py
    ├── static
    │   └── css
    │       └── custom.min.css
    ├── templates
    │   └── index.html
    └── theme.yaml
  • __init__.py

    initiates this package.

    Imports relative to the package can also be made there, for example from . import mymod and from .mymod import func.

  • request_handler.py

    for optional functions, for example, to process HTTP requests and return a dict containing a session token, as described in Request handler hooks.

  • app_hooks.py

    for optional callbacks that can be triggered in different phases of execution, as described in Lifecycle hooks.

  • static

    Subdirectory for static resources of this application.

  • theme.yaml

    for declaring standard attributes that Bokeh should apply to model types.

  • templates

    Subdirectory with a Jinja template index.html. The directory can contain further Jinja templates to which index.html refers.

    Further information can be found at Customizing the application’s Jinja template.

You can find a complete example at: https://github.com/bokeh/bokeh/tree/branch-3.3/examples/server/app/dash. After you have downloaded the dash folder, you can start the Bokeh server with

$ pipenv run python -m bokeh serve --show dash/

$ pipenv run python -m bokeh serve --show examples/app/dash/
2019-02-08 19:02:42,829 Starting Bokeh server version 1.0.4 (running on Tornado 5.1.1)
2019-02-08 19:02:42,835 Bokeh app running at: http://localhost:5006/dash

Bokeh dashboard