Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Module « flask.blueprints »

Classe « Blueprint »

Informations générales

Héritage

builtins.object
    Scaffold
        Blueprint

Définition

class Blueprint(Scaffold):

Description [extrait de Blueprint.__doc__]

Represents a blueprint, a collection of routes and other
    app-related functions that can be registered on a real application
    later.

    A blueprint is an object that allows defining application functions
    without requiring an application object ahead of time. It uses the
    same decorators as :class:`~flask.Flask`, but defers the need for an
    application by recording them for later registration.

    Decorating a function with a blueprint creates a deferred function
    that is called with :class:`~flask.blueprints.BlueprintSetupState`
    when the blueprint is registered on an application.

    See :doc:`/blueprints` for more information.

    :param name: The name of the blueprint. Will be prepended to each
        endpoint name.
    :param import_name: The name of the blueprint package, usually
        ``__name__``. This helps locate the ``root_path`` for the
        blueprint.
    :param static_folder: A folder with static files that should be
        served by the blueprint's static route. The path is relative to
        the blueprint's root path. Blueprint static files are disabled
        by default.
    :param static_url_path: The url to serve static files from.
        Defaults to ``static_folder``. If the blueprint does not have
        a ``url_prefix``, the app's static route will take precedence,
        and the blueprint's static files won't be accessible.
    :param template_folder: A folder with templates that should be added
        to the app's template search path. The path is relative to the
        blueprint's root path. Blueprint templates are disabled by
        default. Blueprint templates have a lower precedence than those
        in the app's templates folder.
    :param url_prefix: A path to prepend to all of the blueprint's URLs,
        to make them distinct from the rest of the app's routes.
    :param subdomain: A subdomain that blueprint routes will match on by
        default.
    :param url_defaults: A dict of default values that blueprint routes
        will receive by default.
    :param root_path: By default, the blueprint will automatically set
        this based on ``import_name``. In certain situations this
        automatic detection can fail, so the path can be specified
        manually instead.

    .. versionchanged:: 1.1.0
        Blueprints have a ``cli`` group to register nested CLI commands.
        The ``cli_group`` parameter controls the name of the group under
        the ``flask`` command.

    .. versionadded:: 0.7
    

Constructeur(s)

Signature du constructeur Description
__init__(self, name: str, import_name: str, static_folder: Union[str, os.PathLike, NoneType] = None, static_url_path: Optional[str] = None, template_folder: Optional[str] = None, url_prefix: Optional[str] = None, subdomain: Optional[str] = None, url_defaults: Optional[dict] = None, root_path: Optional[str] = None, cli_group: Optional[str] = <object object at 0x7f40e98e2d50>)

Liste des attributs statiques

Nom de l'attribut Valeur
json_decoderNone
json_encoderNone
warn_on_modificationsFalse

Liste des propriétés

Nom de la propriétéDescription
has_static_folder``True`` if :attr:`static_folder` is set. [extrait de __doc__]
jinja_loaderThe Jinja loader for this object's templates. By default this [extrait de jinja_loader.__doc__]
static_folderThe absolute path to the configured static folder. ``None`` [extrait de __doc__]
static_url_pathThe URL prefix that the static route will be accessible from. [extrait de __doc__]

Liste des opérateurs

Opérateurs hérités de la classe object

__eq__, __ge__, __gt__, __le__, __lt__, __ne__

Liste des méthodes

Toutes les méthodes Méthodes d'instance Méthodes statiques Méthodes dépréciées
Signature de la méthodeDescription
add_app_template_filter(self, f: Callable[..., Any], name: Optional[str] = None) -> None Register a custom template filter, available application wide. Like [extrait de add_app_template_filter.__doc__]
add_app_template_global(self, f: Callable[..., Any], name: Optional[str] = None) -> None Register a custom template global, available application wide. Like [extrait de add_app_template_global.__doc__]
add_app_template_test(self, f: Callable[..., bool], name: Optional[str] = None) -> None Register a custom template test, available application wide. Like [extrait de add_app_template_test.__doc__]
add_url_rule(self, rule: str, endpoint: Optional[str] = None, view_func: Optional[Callable] = None, provide_automatic_options: Optional[bool] = None, **options: Any) -> None Like :meth:`Flask.add_url_rule` but for a blueprint. The endpoint for [extrait de add_url_rule.__doc__]
after_app_request(self, f: Callable[[ForwardRef('Response')], ForwardRef('Response')]) -> Callable[[ForwardRef('Response')], ForwardRef('Response')] Like :meth:`Flask.after_request` but for a blueprint. Such a function [extrait de after_app_request.__doc__]
app_context_processor(self, f: Callable[[], Dict[str, Any]]) -> Callable[[], Dict[str, Any]] Like :meth:`Flask.context_processor` but for a blueprint. Such a [extrait de app_context_processor.__doc__]
app_errorhandler(self, code: Union[Type[Exception], int]) -> Callable Like :meth:`Flask.errorhandler` but for a blueprint. This [extrait de app_errorhandler.__doc__]
app_template_filter(self, name: Optional[str] = None) -> Callable[[Callable[..., Any]], Callable[..., Any]] Register a custom template filter, available application wide. Like [extrait de app_template_filter.__doc__]
app_template_global(self, name: Optional[str] = None) -> Callable[[Callable[..., Any]], Callable[..., Any]] Register a custom template global, available application wide. Like [extrait de app_template_global.__doc__]
app_template_test(self, name: Optional[str] = None) -> Callable[[Callable[..., bool]], Callable[..., bool]] Register a custom template test, available application wide. Like [extrait de app_template_test.__doc__]
app_url_defaults(self, f: Callable[[str, dict], NoneType]) -> Callable[[str, dict], NoneType] Same as :meth:`url_defaults` but application wide. [extrait de app_url_defaults.__doc__]
app_url_value_preprocessor(self, f: Callable[[Optional[str], Optional[dict]], NoneType]) -> Callable[[Optional[str], Optional[dict]], NoneType] Same as :meth:`url_value_preprocessor` but application wide. [extrait de app_url_value_preprocessor.__doc__]
before_app_first_request(self, f: Callable[[], NoneType]) -> Callable[[], NoneType] Like :meth:`Flask.before_first_request`. Such a function is [extrait de before_app_first_request.__doc__]
before_app_request(self, f: Callable[[], Union[ForwardRef('Response'), ~AnyStr, Dict[str, Any], Generator[~AnyStr, NoneType, NoneType], Tuple[Union[ForwardRef('Response'), ~AnyStr, Dict[str, Any], Generator[~AnyStr, NoneType, NoneType]], Union[ForwardRef('Headers'), Dict[str, Union[str, List[str], Tuple[str, ...]]], List[Tuple[str, Union[str, List[str], Tuple[str, ...]]]]]], Tuple[Union[ForwardRef('Response'), ~AnyStr, Dict[str, Any], Generator[~AnyStr, NoneType, NoneType]], int], Tuple[Union[ForwardRef('Response'), ~AnyStr, Dict[str, Any], Generator[~AnyStr, NoneType, NoneType]], int, Union[ForwardRef('Headers'), Dict[str, Union[str, List[str], Tuple[str, ...]]], List[Tuple[str, Union[str, List[str], Tuple[str, ...]]]]]], ForwardRef('WSGIApplication'), NoneType]]) -> Callable[[], Union[ForwardRef('Response'), ~AnyStr, Dict[str, Any], Generator[~AnyStr, NoneType, NoneType], Tuple[Union[ForwardRef('Response'), ~AnyStr, Dict[str, Any], Generator[~AnyStr, NoneType, NoneType]], Union[ForwardRef('Headers'), Dict[str, Union[str, List[str], Tuple[str, ...]]], List[Tuple[str, Union[str, List[str], Tuple[str, ...]]]]]], Tuple[Union[ForwardRef('Response'), ~AnyStr, Dict[str, Any], Generator[~AnyStr, NoneType, NoneType]], int], Tuple[Union[ForwardRef('Response'), ~AnyStr, Dict[str, Any], Generator[~AnyStr, NoneType, NoneType]], int, Union[ForwardRef('Headers'), Dict[str, Union[str, List[str], Tuple[str, ...]]], List[Tuple[str, Union[str, List[str], Tuple[str, ...]]]]]], ForwardRef('WSGIApplication'), NoneType]] Like :meth:`Flask.before_request`. Such a function is executed [extrait de before_app_request.__doc__]
make_setup_state(self, app: 'Flask', options: dict, first_registration: bool = False) -> flask.blueprints.BlueprintSetupState Creates an instance of :meth:`~flask.blueprints.BlueprintSetupState` [extrait de make_setup_state.__doc__]
record(self, func: Callable) -> None Registers a function that is called when the blueprint is [extrait de record.__doc__]
record_once(self, func: Callable) -> None Works like :meth:`record` but wraps the function in another [extrait de record_once.__doc__]
register(self, app: 'Flask', options: dict) -> None Called by :meth:`Flask.register_blueprint` to register all [extrait de register.__doc__]
register_blueprint(self, blueprint: 'Blueprint', **options: Any) -> None Register a :class:`~flask.Blueprint` on this blueprint. Keyword [extrait de register_blueprint.__doc__]
teardown_app_request(self, f: Callable[[Optional[BaseException]], NoneType]) -> Callable[[Optional[BaseException]], NoneType] Like :meth:`Flask.teardown_request` but for a blueprint. Such a [extrait de teardown_app_request.__doc__]

Méthodes héritées de la classe Scaffold

__init_subclass__, __repr__, __subclasshook__, after_request, before_request, context_processor, delete, endpoint, errorhandler, get, get_send_file_max_age, open_resource, patch, post, put, register_error_handler, route, send_static_file, teardown_request, url_defaults, url_value_preprocessor

Méthodes héritées de la classe object

__delattr__, __dir__, __format__, __getattribute__, __hash__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __str__