class_docstr: Common behavior shared between :class:`~flask.Flask` and
  :class:`~flask.blueprints.Blueprint`.
  
  :param import_name: The import name of the module where this object
      is defined. Usually :attr:`__name__` should be used.
  :param static_folder: Path to a folder of static files to serve.
      If this is set, a static route will be added.
  :param static_url_path: URL prefix for the static route.
  :param template_folder: Path to a folder containing template files.
      for rendering. If this is set, a Jinja loader will be added.
  :param root_path: The path that static, template, and resource files
      are relative to. Typically not set, it is discovered based on
      the ``import_name``.
  
  .. versionadded:: 2.0
class_docstr_tok: ["Common","behavior","shared","between",":","class",":","`","~flask.Flask","`","and",":","class",":","`","~flask.blueprints.Blueprint","`",".",":","param","import_name",":","The","import","name","of","the","module","where","this","object","is","defined",".","Usually",":","attr",":","`","__name__","`","should","be","used",".",":","param","static_folder",":","Path","to","a","folder","of","static","files","to","serve",".","If","this","is","set",",","a","static","route","will","be","added",".",":","param","static_url_path",":","URL","prefix","for","the","static","route",".",":","param","template_folder",":","Path","to","a","folder","containing","template","files",".","for","rendering",".","If","this","is","set",",","a","Jinja","loader","will","be","added",".",":","param","root_path",":","The","path","that","static",",","template",",","and","resource","files","are","relative","to",".","Typically","not","set",",","it","is","discovered","based","on","the","``","import_name","``",".","..","versionadded",":",":","2.0"]
docstr: 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.
  
  This is available on both app and blueprint objects. When used on an app, this
  executes before every request. When used on a blueprint, this executes before
  every request that the blueprint handles. To register with a blueprint and
  execute before every request, use :meth:`.Blueprint.before_app_request`.
docstr_tok: ["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",".","This","is","available","on","both","app","and","blueprint","objects",".","When","used","on","an","app",",","this","executes","before","every","request",".","When","used","on","a","blueprint",",","this","executes","before","every","request","that","the","blueprint","handles",".","To","register","with","a","blueprint","and","execute","before","every","request",",","use",":","meth",":","`",".Blueprint.before_app_request","`","."]
code: def before_request(self, f: T_before_request) -> T_before_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.
  
      This is available on both app and blueprint objects. When used on an app, this
      executes before every request. When used on a blueprint, this executes before
      every request that the blueprint handles. To register with a blueprint and
      execute before every request, use :meth:`.Blueprint.before_app_request`.
      """
      self.before_request_funcs.setdefault(None, []).append(f)
      return f
  
imports: from __future__ import annotations
  import importlib.util
  import os
  import pathlib
  import sys
  import typing
  from collections import defaultdict
  from functools import update_wrapper
  from jinja2 import FileSystemLoader
  from werkzeug.exceptions import default_exceptions
  from werkzeug.exceptions import HTTPException
  from werkzeug.utils import cached_property
  from ..None import typing
  from ..cli import AppGroup
  from ..helpers import get_root_path
  from ..templating import _default_template_ctx_processor
label_desc: Use image node_id 19 for calling the Scaffold obj's underlying member method code with example usage: obj.before_request(f) and returns: f