abstractkitchen / flask-backbone

[2023] Modern Flask Boilerplate with a well-organised structure.

Home Page:https://abstractkitchen.com/blog/flask-backbone/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Flask-Backbone

Your Next Flask Boilerplate

Create sitemaps with Sitemapa

UPD: March 15, 2023

  • Removed alembic from the codebase. You can install by yourself.
  • Removed SQLAlchemy extensions to avoid unnecessary complexity in the blueprint.
  • Added .env support for the application config with from_prefixed_env. Check app.py for the details.
    • Access FLASK_MY_CONFIG_PROP as app.config.get("MY_CONFIG_PROP").
    • Priorities: .env > config/{env}.py > instance/config.py. Instance folder config is top priority.
  • SQLAlchemy 2 support
  • Added Python Typing
  • Moved to Python 3.11

Features

  • Predefined basic structure, so you'll end up with a clean architecture.
  • Database support via SQLAlchemy. However, you can skip database setup and use Flask-Backbone without the database. I also do not use Flask-SQLAlchemy, but you can.
  • Development/Production/You own configs with instance_relative_config.
  • Cache support via flask_caching. Setup easily with configuration.
  • Flask-Debug
  • Sentry support. Just add your DSN, and you're good to go.
  • Jinja filters and custom variables.
  • Designed to be blueprint-first. Keep your structure clean and steady with blueprints. Everything is a blueprint. Your future self will thank you.
  • Interactive commands to create your next blueprint. Define your blueprint skeletons to speed up your development. To create your next blueprint simply run flask app create-blueprint. It's up to you and you can completely ignore or remove this part and everything will work perfectly fine.
  • Initial setup with a configuration script.
  • WSGI config

Getting Started

Note: Tested with Python 3.11

1 — Clone flask-backbone.

git clone https://github.com/abstractkitchen/flask-backbone.git .

2 — As a rule of thumb, make sure that you use a virtual environment. For example python3 -m venv pythonenv. This will create an environment in the folder pythonenv. I prefer to name my python environment as a pythonenv, because it's more descriptive.

python3 -m venv pythonenv

. pythonenv/bin/activate

pip install -r requirements.txt

3 — Launch configure.py. It will ask you some question about your future setup. python configure.py

This utility will create: .env and instance/config.py.

Usage

Please read this article. You'll learn more details about the boilerplate and Flask.

Read about usage on my website.

Contacts

License

MIT

About

[2023] Modern Flask Boilerplate with a well-organised structure.

https://abstractkitchen.com/blog/flask-backbone/

License:MIT License


Languages

Language:Python 96.2%Language:Jinja 3.8%