Skip to main content

Flask blueprints auto discovery

Project description

Blueprints

Blueprints is a library to perform auto-discovery of Flask blueprints by scanning the installed packages for blueprints.txt files.

Discovery

Discovery of blueprints is performed by the register_blueprints method. All discovered blueprints are stored in a blueprints attribute of the blueprints package. The attribute is a dictionary containing the blueprint name and associated meta data.

If a blueprint has the url_prefix specified then it is used. Otherwise, the package name containing the blueprint is used as the url_prefix.

Installation

pip install --upgrade auto-blueprints

Running

Blueprints can be run as a module.

python -m blueprints

Blueprints can be run as a command line executable.

blueprints --host 127.0.0.1 --port 5000

If waitress is installed then a server using waitress is started. If waitress is not installed then the flask development server is started.

Embedding

Blueprints can be embedded in an existing program very simply.

from flask import Flask
from blueprints import register_blueprints
app = Flask(__name__)
register_blueprints('blueprints.txt', app)
app.run()

blueprints.txt format

The blueprints.txt file is a multi-line file containing one line per blueprint to import. The structure of the line is ...

hello.entry.bp  => imports hello.entry and retrieves the bp attribute containing a flask blueprint

License

MIT Licensed

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

auto_blueprints-0.1.1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

auto_blueprints-0.1.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file auto_blueprints-0.1.1.tar.gz.

File metadata

  • Download URL: auto_blueprints-0.1.1.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for auto_blueprints-0.1.1.tar.gz
Algorithm Hash digest
SHA256 da109c09cd29f2ed6451ecfcd0a8bf61858bc3a1c0b2c465ba12d04afe337c3d
MD5 0a68baf488b0cf1c14b1127cc3b51329
BLAKE2b-256 c5efcaa4ca56494b383a7c4fb6486c1da23b79e4de2035fb307129824debdb72

See more details on using hashes here.

File details

Details for the file auto_blueprints-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for auto_blueprints-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 029db087854f4636fbccbff0707919f4ce99239f506f9d7fea4318760ea97a02
MD5 193709b05635c3f940abc86932a6d421
BLAKE2b-256 0b7006b0813f05db50d109b7f1c89b4ed10351d0fd5e5359f42431b60b418321

See more details on using hashes here.

Supported by

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