A simple comic viewer for Dilbert by Scott Adams. This is meant to be hosted on Heroku here, using the third-party Python Poetry Buildpack with the Heroku PostgreSQL add-on for caching.
This is now deprecated in favour of a Rust-based version in this repository.
Run the script cache_init.sql
at the beginning to create the required tables in the cache:
heroku pg:psql -a dilbert-viewer -f cache_init.sql
Poetry is used for conveniently installing and managing dependencies. The Heroku CLI is used to locally run the code as specified in the Procfile.
-
[Optional] Create a virtual environment with a compatible Python version (specified in pyproject.toml).
-
Install Poetry globally (recommended), or in a virtual environment. Please refer to Poetry's installation guide for recommended installation options.
You can use pip to install it:
pip install poetry
-
Install all dependencies with Poetry:
poetry install --no-dev
If you didn't create and activate a virtual environment in step 1, Poetry creates one for you and installs all dependencies there.
-
Install the Heroku CLI. Please refer to Heroku's installation guide for recommended installation options.
-
Activate the virtual environment where you installed the dependencies. To use the virtual environment created by Poetry, run:
poetry shell
-
Set the required environment variables and run the viewer locally with the Heroku CLI:
DATABASE_URL=$(heroku config:get DATABASE_URL -a dilbert-viewer) WEB_CONCURRENCY=1 heroku local web
pre-commit is used for managing hooks that run before each commit, to ensure code quality and run some basic tests. Thus, this needs to be set up only when one intends to commit changes to git.
-
Activate the virtual environment where you installed the dependencies.
-
Install all dependencies, including extra dependencies for development:
poetry install
-
Install pre-commit hooks:
pre-commit install
NOTE: You need to be inside the virtual environment where you installed the above dependencies every time you commit. However, this is not required if you have installed pre-commit globally.