flask.Blueprint
¶
-
class
flask.
Blueprint
(name, import_name, static_folder=None, static_url_path=None, template_folder=None, url_prefix=None, subdomain=None, url_defaults=None, root_path=None)[source]¶ Represents a blueprint. A blueprint is an object that records functions that will be called with the
BlueprintSetupState
later to register functions or other things on the main application. See Modular Applications with Blueprints for more information.New in version 0.7.
Methods¶
__init__ (name, import_name[, static_folder, ...]) |
|
add_app_template_filter (f[, name]) |
Register a custom template filter, available application wide. |
add_app_template_global (f[, name]) |
Register a custom template global, available application wide. |
add_app_template_test (f[, name]) |
Register a custom template test, available application wide. |
add_url_rule (rule[, endpoint, view_func]) |
Like Flask.add_url_rule() but for a blueprint. |
after_app_request (f) |
Like Flask.after_request() but for a blueprint. |
after_request (f) |
Like Flask.after_request() but for a blueprint. |
app_context_processor (f) |
Like Flask.context_processor() but for a blueprint. |
app_errorhandler (code) |
Like Flask.errorhandler() but for a blueprint. |
app_template_filter ([name]) |
Register a custom template filter, available application wide. |
app_template_global ([name]) |
Register a custom template global, available application wide. |
app_template_test ([name]) |
Register a custom template test, available application wide. |
app_url_defaults (f) |
Same as url_defaults() but application wide. |
app_url_value_preprocessor (f) |
Same as url_value_preprocessor() but application wide. |
before_app_first_request (f) |
Like Flask.before_first_request() . |
before_app_request (f) |
Like Flask.before_request() . |
before_request (f) |
Like Flask.before_request() but for a blueprint. |
context_processor (f) |
Like Flask.context_processor() but for a blueprint. |
endpoint (endpoint) |
Like Flask.endpoint() but for a blueprint. |
errorhandler (code_or_exception) |
Registers an error handler that becomes active for this blueprint only. |
get_send_file_max_age (filename) |
Provides default cache_timeout for the send_file() functions. |
make_setup_state (app, options[, ...]) |
Creates an instance of BlueprintSetupState() object that is later passed to the register callback functions. |
open_resource (resource[, mode]) |
Opens a resource from the application’s resource folder. |
record (func) |
Registers a function that is called when the blueprint is registered on the application. |
record_once (func) |
Works like record() but wraps the function in another function that will ensure the function is only called once. |
register (app, options[, first_registration]) |
Called by Flask.register_blueprint() to register a blueprint on the application. |
register_error_handler (code_or_exception, f) |
Non-decorator version of the errorhandler() error attach function, akin to the register_error_handler() application-wide function of the Flask object but for error handlers limited to this blueprint. |
route (rule, **options) |
Like Flask.route() but for a blueprint. |
send_static_file (filename) |
Function used internally to send static files from the static folder to the browser. |
teardown_app_request (f) |
Like Flask.teardown_request() but for a blueprint. |
teardown_request (f) |
Like Flask.teardown_request() but for a blueprint. |
url_defaults (f) |
Callback function for URL defaults for this blueprint. |
url_value_preprocessor (f) |
Registers a function as URL value preprocessor for this blueprint. |
Attributes¶
has_static_folder |
This is True if the package bound object’s container has a folder for static files. |
jinja_loader |
The Jinja loader for this package bound object. |
static_folder |
The absolute path to the configured static folder. |
static_url_path |
|
warn_on_modifications |