Skip to content

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.

License

Notifications You must be signed in to change notification settings

Dosenpfand/zug-lol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mypy logo

zug.lol

CI codecov License: MIT Code style: black pre-commit mypy: checked

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.

Components

The application uses the following components.

  1. Flask for the backend
  2. htmx for asynchronous HTTP requests and server-sent events
  3. Bootstrap for front end layout

Run

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.

  1. Install and switch to the supported Python version:

    pyenv install 3.9 && pyenv local 3.9
    
  2. Create and activate a virtual environment

    python -m venv venv
    source venv/bin/activate
    
  3. Install dependencies

    pip install -r requirements.txt
    
  4. For local development install additional dependencies

    pip install -r requirements-dev.txt
    

    and install the pre-commit hooks

    pre-commit install
    
  5. Setup a PostgreSQL database and configure it via

  6. Adapt the config, either by changing the contents in config.py, or by pointing the environment variable APPLICATION_SETTINGS to an alternative file, or by setting environment variables with the FLASK_ 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.

  7. Initialize the database

    flask init-db
    
  8. 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
  9. Upgrade the database schema:

    flask db migrate
    flask db upgrade
  10. Run the app

    export FLASK_DEBUG=True
    export FLASK_APP=app
    flask run
    
  11. Open in your browser: http://localhost:5000

Live Demo

A live version can be reached at https://zug.lol

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published