src/flask/scaffold.py
def before_request(self, f: BeforeRequestCallable) -> BeforeRequestCallable:
        """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.
        """
        self.before_request_funcs.setdefault(None, []).append(f)
        return f
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.
        
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



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.
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 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 .
def before_request(self, f: BeforeRequestCallable) -> BeforeRequestCallable:
        self.before_request_funcs.setdefault(None, []).append(f)
        return f
def before_request ( self , f : BeforeRequestCallable ) -> BeforeRequestCallable : self . before_request_funcs . setdefault ( None , [ ] ) . append ( f ) return f
Register a function to run before each request.
Register a function to run before each request .
"""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.
        """
self
f
BeforeRequestCallable