Basic URL shortener written in Python. Dependencies:
- Flask as the framework
- SQLAlchemy for the ORM
- Flask-SQLAlchemy for better integration with Flask
- Flask-Migrate to handle migrations with Alembic
- Marshmallow for a tiny bit of validation
- Black for formatting
- mypy for static type checking
The word itself is a vowel-less version of kratek, meaning short in Slovenian. Also sounds like krtek which seemed cute.
# Create/run containers (krtk flask app and postgresql database)
docker compose up
# After first startup run migrations
docker compose exec krtk flask db upgradeSee Importing from MySQL dump.
Things are handled with pipenv:
# Install dependencies
pipenv install -d
# Go into the virtualenv
pipenv shell
# Start the app
flask run --debug
# Run type checker
pipenv run check-types
# Run formatter
pipenv run format
# Run tests
pipenv run testDatabase migrations use alembic through Flask-Migrate, refer to the
official documentation.
Two everyday things you might need:
# Run any outstanding migrations (needed before first run)
flask db upgrade
# Generate new migration after modifying model in db.py
flask db migrate -m "Add field X to table Y"