Skip to content

2.3.1

Compare
Choose a tag to compare
@CheeseCake87 CheeseCake87 released this 31 Aug 20:51

Overhaul to the import engine, auto import is now able to import vanilla Blueprints.

THIS VERSION HAS BREAKING CHANGES FROM VERSION 2.2.*

.import_global_collection() has been replaced by .import_app_resources()

This gives more control to importing app based resources.

bigapp.import_app_resources(
    folder = folder to import resources from
    app_factories = function names that the app instance will be passed to
    static_folder = "static" sets app.static_folder to None if not found
    templates_folder = "templates"  sets app.template_folder to None if not found
    scope_root_folders_to = [List of folders to import from, ignores other not on this list],
    scope_root_files_to =  [List of files to import from, ignores other not on this list],
)

An example of the simplest use case:

folder structure

Project/
    app/
        global/
            route.py
            another_route.py
    __init__.py
    venv/...

__init__.py

def create_app():
    app = Flask(__name__)
    bigapp.init_app(app)

    bigapp.import_app_resources()  # will look for global folder by default

    return app

global/route.py

from flask import current_app as app


@app.route("/")
def index():
    return "index"

global/another_route.py

from flask import current_app as app


@app.route("/another")
def another():
    return "another"