/flask-bokeh-dashboard

Walking skeleton for Bokeh plots in a Material Design dashboard interacting with Flask.

Primary LanguageHTMLBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

Material Dashboard with Bokeh embedded in Flask

Contributors License

Features

The package provides a starter pack with an interactive Bokeh plot embedded in a Material Design Dashboard, which can send parameters from a flask form to Bokeh.

Material Dashboard with Bokeh embedded in Flask

Note

Please keep in mind that this is only a lightweight example of how Flask can affect the rendering of the bokeh plot. The change in scale is out of scope.

Quickstart

Before you install Python packages, you must meet a few requirements.

  1. Make sure you use the desired Python version:

    $ python --version
    Python 3.7.3
    
    Only Python >=3.6 is supported.
  2. Make sure that Pip is installed:

    $ pip --version
    pip 18.1
  3. If Pip isn’t installed, you can install it with:

    $ sudo apt install python3-venv python3-pip
  4. Install Pipenv:

    $ pip3 install --user pipenv
      Downloading pipenv-2018.7.1-py3-none-any.whl (5.0MB): 5.0MB downloaded
    Requirement already satisfied (use --upgrade to upgrade): virtualenv in /usr/lib/python3/dist-packages (from pipenv)
    Installing collected packages: pipenv, certifi, pip, setuptools, virtualenv-clone
    
    Successfully installed pipenv certifi pip setuptools virtualenv-clone
    Cleaning up...
  5. Download:

    $ curl -O https://github.com/veit/flask-bokeh-dashboard/archive/master.zip
    $ unzip master.zip
  6. Create virtual environment:

    $ cd flask-bokeh-dashboard
    $ pipenv install
    Creating a virtualenv for this project…
    
    Updated Pipfile.lock
    
    Installing dependencies from Pipfile.lock Updated Pipfile.lock (f042ee)…
    
  7. Run the dashboard with the gunicorn command:

    $ pipenv run gunicorn -w 1 main:app
    [2021-09-08 10:10:16 +0200] [55490] [INFO] Starting gunicorn 20.1.0
    [2021-09-08 10:10:16 +0200] [55490] [INFO] Listening at: http://127.0.0.1:8000 (55490)
    [2021-09-08 10:10:16 +0200] [55490] [INFO] Using worker: sync
    [2021-09-08 10:10:16 +0200] [55498] [INFO] Booting worker with pid: 55498

    Note

    The w option can be used to specify the number of workers.

  8. Visit http://127.0.0.1:8000 and it should look like the screenshot above.

  9. You can shut down the service in the console with ctrl-c.

Pull requests

If you have differences in your preferred setup, I encourage you to fork this to create your own version. I also accept pull requests on this, if they are small, atomic, and if they make my own packaging experience better.