Skip to content

textbook/flash

Repository files navigation

Flash

GitHub Actions Build Status Test Coverage Other Code Issues ISC License

Flask + Dashboard = Flash. A project dashboard that works.

Deploying it

  1. Heroku

    Deploy to Heroku

  2. Cloud Foundry

    Flash can easily be deployed to any Cloud Foundry environment. An example manifest.yml is included with the project, showing how to configure the deployment with an app name and a random route. Once you have installed the CLI and selected an appropriate target org and space, you can simply cf push.

  3. Docker

    Alternatively, build a Docker container as below and deploy to an online container hosting service.

Configuring it

There are three environment variables that Flash is aware of:

  • PORT - the port to bind to (defaults to 5000)
  • FLASK_SECRET_KEY - the secret key for Flask sessions (they aren't currently used, but it's good practice to set it to a random value)
  • FLASH_CONFIG - the configuration, described below

The configuration, either saved in config.json at the project root or as the $FLASH_CONFIG environment variable, should look like:

{
  "project_name": <name of the project>,
  "services": [
    {
      "name": "tracker",
      "api_token": <your API token>,
      "project_id": <your project ID>
    }
  ]
}

If both the environment variable and the config file are provided, the environment variable takes precedence.

If loading from config.json, any value in the "services" settings that $LOOKS_LIKE_THIS (leading $, capital letters and underscores only) will be assumed to be an environment variable and retrieved accordingly. This lets you version control most of your configuration without leaking API tokens and other secrets.

Settings

  • project_name - the project's name to display in the footer (defaults to "unnamed")
  • services - an array of service configurations (see flash_services for details and configuration options)
  • style - the stylesheet to use (defaults to "default", which is currently the only option...)
  • project_end - the end data and time of the project, in any format accepted by Moment.js. If provided, a countdown to this point will be shown in the footer (no default, if not provided no countdown is shown).

Running it

If you just want to run Flash locally, you can use the included Dockerfile to build and run a Docker container. This is a two-step process, after which Flash will be available at http://localhost:5000:

docker build -t textbook/flash .
docker run -p 5000:80 textbook/flash

If your config.json includes environment variable references, or you want to override the configuration completely with $FLASH_CONFIG, you can supply environment variables at docker run time with the -e command.

Developing it

The easiest way to install Flash for development is:

  1. Install the dependencies: pip3 install -r requirements.txt
  2. Install the package in development mode: python3 setup.py develop
  3. To run it locally, edit flash/config.json or provide $FLASH_CONFIG then run: python3 scripts/launch.py
  4. To run the tests, use python setup.py test or run py.test directly. In the latter case, use --runslow --Chrome (or another browser of your choice) to include the integration tests, and see the docs for pytest-pylint configuration options. For the integration tests you will need to ensure that chromedriver is on your PATH; on OS X, you can simply brew cask install chromedriver.

The templates are written using the Jinja2 template language.

Thunder

Thunder is a new branch in the Flash repository that might eventually replace the original. It switches the framework from Flask to Tornado, allowing asynchronous processing and websockets.