Classe « Scaffold »
Signature de la méthode before_request
def before_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]]
Description
before_request.__doc__
Register a function to run before each request.
For example, this can be used to open a database connection, or
to load the logged in user from the session.
.. code-block:: python
@app.before_request
def load_user():
if "user_id" in session:
g.user = db.session.get(session["user_id"])
The function will be called without any arguments. If it returns
a non-``None`` value, the value is handled as if it was the
return value from the view, and further request handling is
stopped.
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 :