A web application that can retrieves prices for train journeys within Austria (via oebb.at) and allows you to create a travel journal to determine if a Klimaticket pays off.
The application uses the following components.
- Flask for the backend
- htmx for asynchronous HTTP requests and server-sent events
- Bootstrap for front end layout
To run the application locally you can use docker-compose:
docker-compose up --build -d
You should now be able to browse the app at http://localhost:5000 .
If you want to restore an existing database backup, place its .sql
in the db_backup/
folder before running the above command.
Please note that when using this method the database will not be persistent. For persistence uncomment the corresponding lines in the docker-compose.yml
file.
For a docker-free setup follow these steps.
-
Install and switch to the supported Python version:
pyenv install 3.9 && pyenv local 3.9
-
Create and activate a virtual environment
python -m venv venv source venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
For local development install additional dependencies
pip install -r requirements-dev.txt
and install the pre-commit hooks
pre-commit install
-
Setup a PostgreSQL database and configure it via
-
Adapt the config, either by changing the contents in
config.py
, or by pointing the environment variableAPPLICATION_SETTINGS
to an alternative file, or by setting environment variables with theFLASK_
prefix. At least the following variables need to be set/changed:FLASK_SECRET_KEY # should be generated by secrets.token_urlsafe() FLASK_SECURITY_PASSWORD_SALT # should be generated by secrets.SystemRandom().getrandbits(128) SQLALCHEMY_DATABASE_URI # Should point to the database configured in the previous step RECAPTCHA_PUBLIC_KEY RECAPTCHA_PRIVATE_KEY
If Sentry error reporting should be performed
SENTRY_DSN
needs to be set. -
Initialize the database
flask init-db
-
Adapt the translation
pybabel extract -F babel.cfg -k lazy_gettext -o messages.pot . pybabel update -i messages.pot -d app/translations # Adapt app/translations/de/LC_MESSAGES/messages.po pybabel compile -d app/translations
-
Upgrade the database schema:
flask db migrate flask db upgrade
-
Run the app
export FLASK_DEBUG=True export FLASK_APP=app flask run
-
Open in your browser: http://localhost:5000
A live version can be reached at https://zug.lol