Skip to main content

FlaskSpark is a lightweight and customizable Flask boilerplate designed to ignite your web application development process.

Project description

FlaskSpark

FlaskSpark is a lightweight Flask framework with a clear project structure, automatic class-based view registration, built-in SQLAlchemy + Flask-Migrate wiring, optional OAuth/OIDC login, and an asset pipeline for SCSS/JS.

Features

  • App bootstrap with configurable app_module
  • Auto-registration of class-based views (as_view())
  • SQLAlchemy + Flask-Migrate integration
  • Pluggable login providers (Default, OAuth)
  • OAuth/OIDC support via authlib
  • Built-in i18n with Flask-Babel
  • Static/template fallback (app first, FlaskSpark second)
  • Optional SCSS/JS bundling via Flask-Assets

Requirements

  • Python 3.8+
  • pip

Installation

pip install FlaskSpark

Development (editable):

pip install -e .

Quick Start

from flaskspark import FlaskSpark

app = FlaskSpark(
    app_module="app",
    config={
        "SECRET_KEY": "change-me",
        "SQLALCHEMY_DATABASE_URI": "sqlite:///instance/app.db",
        "BABEL_SUPPORTED_LOCALES": ["en", "de"],
    },
).app

Expected app layout:

app/
  __init__.py
  views/
    home.py
  models/
    __init__.py
  templates/
  static/

Class-Based Views

Any class in app.views implementing as_view() is auto-registered.

from flaskspark.views.flaskspark_method_view import FlaskSparkMethodView
from flask import render_template

class HomeView(FlaskSparkMethodView):
    url = "/"
    endpoint = "home"

    def get(self):
        return render_template("index.html")

OAuth (OIDC) Login Provider

Enable OAuth provider:

FlaskSpark(login_provider="OAuth")

Required config:

OAUTH_NAME
OAUTH_AUTHORIZE_URL
OAUTH_ACCESS_TOKEN_URL
OAUTH_USERINFO_ENDPOINT
OAUTH_JWKS_URI
OAUTH_CLIENT_ID
OAUTH_CLIENT_SECRET
OAUTH_SCOPE

Optional role mapping:

OAUTH_GROUPS_CLAIM=groups
OAUTH_ROLE_PRIORITY=admins,editors,users
OAUTH_ROLE_MAP=admins:Administrators,editors:Editors,users:Users

Database & Migrations

FLASK_APP=app.py python -m flask db init
FLASK_APP=app.py python -m flask db migrate -m "init"
FLASK_APP=app.py python -m flask db upgrade

Assets (SCSS / JS)

FlaskSpark can build SCSS and JS bundles:

FlaskSpark(
    app_module="app",
    config={
        "ASSETS_ENABLE": True,
        "ASSETS_AUTO_BUILD": True,
        "ASSETS_BUNDLES": [
            {
                "name": "dashboard_js",
                "type": "js",
                "entry": "js/dashboard.js",
                "output": "scripts/dashboard.min.js",
                "filters": "rjsmin",
            },
        ],
    },
)

i18n

FlaskSpark initializes Babel and provides a client-side translation endpoint:

GET /_flaskspark/i18n?keys=Key%201,Key%202

Configuration

Common keys:

SECRET_KEY = "..."
SQLALCHEMY_DATABASE_URI = "sqlite:///instance/app.db"
APP_BIND_HOST = "0.0.0.0"
APP_PORT = 5067
BABEL_DEFAULT_LOCALE = "en"
BABEL_SUPPORTED_LOCALES = ["en", "de"]

License

MIT License. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flaskspark-0.1.0.tar.gz (85.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flaskspark-0.1.0-py3-none-any.whl (91.7 kB view details)

Uploaded Python 3

File details

Details for the file flaskspark-0.1.0.tar.gz.

File metadata

  • Download URL: flaskspark-0.1.0.tar.gz
  • Upload date:
  • Size: 85.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for flaskspark-0.1.0.tar.gz
Algorithm Hash digest
SHA256 894afde222cfee60d6f6de28f1e6848669b7d6188bc9f962161b786e904d158f
MD5 2f3f1d8ce62d5fec5a8a4fd848a2f489
BLAKE2b-256 034e386ed5d07faea1b3b877faa555f690c4c69ae35c24272d75e4f94237a257

See more details on using hashes here.

Provenance

The following attestation bundles were made for flaskspark-0.1.0.tar.gz:

Publisher: publish-pypi.yml on berofa/FlaskSpark

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flaskspark-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: flaskspark-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 91.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for flaskspark-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 150bd0e6f9ca22798bf5e3c94283ed010500cf91066b6fbf8154008e99367fcc
MD5 23f264a416827455fc761482baae8286
BLAKE2b-256 3add6179c573fe897c4cfcba386c49b868d4003fece1a8241cfcffd0370e7f64

See more details on using hashes here.

Provenance

The following attestation bundles were made for flaskspark-0.1.0-py3-none-any.whl:

Publisher: publish-pypi.yml on berofa/FlaskSpark

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page