Flask Blueprint Autoimporter
flask-blueprints will import and register all nested Flask Blueprints under a given package directory.
Synopsis
Register all Flask Blueprints (including nested) from a package directory.
Usage
Create an empty package app.blueprints and register your blueprints:
from flask import Flask
from flask_blueprints import register_blueprints
app = Flask(__name__)
register_blueprints(app, 'app.blueprints')
Blueprints can now be placed under this package, as such:
.
└── app
├── blueprints
│ ├── account
│ │ ├── account.py
│ │ ├── contact
│ │ │ ├── contact.py
│ │ │ └── __init__.py
│ │ └── __init__.py
│ ├── api
│ │ ├── account
│ │ │ ├── account.py
│ │ │ ├── contact
│ │ │ │ ├── contact.py
│ │ │ │ └── __init__.py
│ │ │ └── __init__.py
│ │ ├── __init__.py
│ │ └── user
│ │ ├── __init__.py
│ │ └── tribute.py
│ ├── __init__.py
│ └── project
│ ├── documents.py
│ ├── __init__.py
│ ├── project.py
│ └── search.py
└── __init__.py
Blueprint __init__.py files should look something like the following:
from flask import Blueprint
bp = Blueprint('project', __name__)
from . import documents
from . import project
from . import search
(Note that the top-level app/blueprints/__init__.py is not a blueprint
package, and therefore should not have a blueprint defined.)
The blueprint files themselves can then define the routes. For example:
from flask import redirect, url_for
from . import bp
@bp.post('/project/<int:project_id>/store')
def store(project_id):
# ...
return redirect(url_for('project.show', project_id=project_id))
If the blueprint variable is not bp, then this can be customised:
register_blueprints(app, 'app.blueprints', bp='bp')
Further Reading
Metadata
Release files for flask-blueprints 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flask-blueprints-0.0.6.tar.gz | 3.3 kB | Without provenance | Details for flask-blueprints-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flask_blueprints-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for flask_blueprints-0.0.6-py3-none-any.whl |
Total release size: 6.9 kB
Release files / flask-blueprints-0.0.6.tar.gz
| Download URL | flask-blueprints-0.0.6.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
db3b5b85c64bd34e28b0eb9acca9701d8c19b741d02d9eb92340bfdf34a51b89
|
|
BLAKE2b-256 checksum How to use checksums |
8fd65486370b10c93a2dec359e1550c5ad176dbf8b1d48514204bf4a9e2a8fe1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.8
|
Release files / flask_blueprints-0.0.6-py3-none-any.whl
| Download URL | flask_blueprints-0.0.6-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6b9b4e8e3c173dcf807245284442838fc6e8c113c85adaab9457af9750dfda2a
|
|
BLAKE2b-256 checksum How to use checksums |
1fab443f65632b49107c753d846e9dcd141f63e5a98f1b624bec619e4eaf06ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.8
|
Security for flask-blueprints 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.