class_docstr: The flask object implements a WSGI application and acts as the central
  object.  It is passed the name of the module or package of the
  application.  Once it is created it will act as a central registry for
  the view functions, the URL rules, template configuration and much more.
  
  The name of the package is used to resolve resources from inside the
  package or the folder the module is contained in depending on if the
  package parameter resolves to an actual python package (a folder with
  an :file:`__init__.py` file inside) or a standard module (just a ``.py`` file).
  
  For more information about resource loading, see :func:`open_resource`.
  
  Usually you create a :class:`Flask` instance in your main module or
  in the :file:`__init__.py` file of your package like this::
  
      from flask import Flask
      app = Flask(__name__)
  
  .. admonition:: About the First Parameter
  
      The idea of the first parameter is to give Flask an idea of what
      belongs to your application.  This name is used to find resources
      on the filesystem, can be used by extensions to improve debugging
      information and a lot more.
  
      So it's important what you provide there.  If you are using a single
      module, `__name__` is always the correct value.  If you however are
      using a package, it's usually recommended to hardcode the name of
      your package there.
  
      For example if your application is defined in :file:`yourapplication/app.py`
      you should create it with one of the two versions below::
  
          app = Flask('yourapplication')
          app = Flask(__name__.split('.')[0])
  
      Why is that?  The application will work even with `__name__`, thanks
      to how resources are looked up.  However it will make debugging more
      painful.  Certain extensions can make assumptions based on the
      import name of your application.  For example the Flask-SQLAlchemy
      extension will look for the code in your application that triggered
      an SQL query in debug mode.  If the import name is not properly set
      up, that debugging information is lost.  (For example it would only
      pick up SQL queries in `yourapplication.app` and not
      `yourapplication.views.frontend`)
  
  .. versionadded:: 0.7
     The `static_url_path`, `static_folder`, and `template_folder`
     parameters were added.
  
  .. versionadded:: 0.8
     The `instance_path` and `instance_relative_config` parameters were
     added.
  
  .. versionadded:: 0.11
     The `root_path` parameter was added.
  
  .. versionadded:: 1.0
     The ``host_matching`` and ``static_host`` parameters were added.
  
  .. versionadded:: 1.0
     The ``subdomain_matching`` parameter was added. Subdomain
     matching needs to be enabled manually now. Setting
     :data:`SERVER_NAME` does not implicitly enable it.
  
  :param import_name: the name of the application package
  :param static_url_path: can be used to specify a different path for the
                          static files on the web.  Defaults to the name
                          of the `static_folder` folder.
  :param static_folder: The folder with static files that is served at
      ``static_url_path``. Relative to the application ``root_path``
      or an absolute path. Defaults to ``'static'``.
  :param static_host: the host to use when adding the static route.
      Defaults to None. Required when using ``host_matching=True``
      with a ``static_folder`` configured.
  :param host_matching: set ``url_map.host_matching`` attribute.
      Defaults to False.
  :param subdomain_matching: consider the subdomain relative to
      :data:`SERVER_NAME` when matching routes. Defaults to False.
  :param template_folder: the folder that contains the templates that should
                          be used by the application.  Defaults to
                          ``'templates'`` folder in the root path of the
                          application.
  :param instance_path: An alternative instance path for the application.
                        By default the folder ``'instance'`` next to the
                        package or module is assumed to be the instance
                        path.
  :param instance_relative_config: if set to ``True`` relative filenames
                                   for loading the config are assumed to
                                   be relative to the instance path instead
                                   of the application root.
  :param root_path: The path to the root of the application files.
      This should only be set manually when it can't be detected
      automatically, such as for namespace packages.
class_docstr_tok: ["The","flask","object","implements","a","WSGI","application","and","acts","as","the","central","object",".","It","is","passed","the","name","of","the","module","or","package","of","the","application",".","Once","it","is","created","it","will","act","as","a","central","registry","for","the","view","functions",",","the","URL","rules",",","template","configuration","and","much","more",".","The","name","of","the","package","is","used","to","resolve","resources","from","inside","the","package","or","the","folder","the","module","is","contained","in","depending","on","if","the","package","parameter","resolves","to","an","actual","python","package","(","a","folder","with","an",":","file",":","`","__init__.py","`","file","inside",")","or","a","standard","module","(","just","a","``",".py","``","file",")",".","For","more","information","about","resource","loading",",","see",":","func",":","`","open_resource","`",".","Usually","you","create","a",":","class",":","`","Flask","`","instance","in","your","main","module","or","in","the",":","file",":","`","__init__.py","`","file","of","your","package","like","this",":",":","from","flask","import","Flask","app","=","Flask","(","__name__",")","..","admonition",":",":","About","the","First","Parameter","The","idea","of","the","first","parameter","is","to","give","Flask","an","idea","of","what","belongs","to","your","application",".","This","name","is","used","to","find","resources","on","the","filesystem",",","can","be","used","by","extensions","to","improve","debugging","information","and","a","lot","more",".","So","it","'s","important","what","you","provide","there",".","If","you","are","using","a","single","module",",","`","__name__","`","is","always","the","correct","value",".","If","you","however","are","using","a","package",",","it","'s","usually","recommended","to","hardcode","the","name","of","your","package","there",".","For","example","if","your","application","is","defined","in",":","file",":","`","yourapplication\/app.py","`","you","should","create","it","with","one","of","the","two","versions","below",":",":","app","=","Flask","(","'yourapplication","'",")","app","=","Flask","(","__name__.split","(","'",".","'",")","[","0","]",")","Why","is","that","?","The","application","will","work","even","with","`","__name__","`",",","thanks","to","how","resources","are","looked","up",".","However","it","will","make","debugging","more","painful",".","Certain","extensions","can","make","assumptions","based","on","the","import","name","of","your","application",".","For","example","the","Flask-SQLAlchemy","extension","will","look","for","the","code","in","your","application","that","triggered","an","SQL","query","in","debug","mode",".","If","the","import","name","is","not","properly","set","up",",","that","debugging","information","is","lost",".","(","For","example","it","would","only","pick","up","SQL","queries","in","`","yourapplication.app","`","and","not","`","yourapplication.views.frontend","`",")","..","versionadded",":",":","0.7","The","`","static_url_path","`",",","`","static_folder","`",",","and","`","template_folder","`","parameters","were","added",".","..","versionadded",":",":","0.8","The","`","instance_path","`","and","`","instance_relative_config","`","parameters","were","added",".","..","versionadded",":",":","0.11","The","`","root_path","`","parameter","was","added",".","..","versionadded",":",":","1.0","The","``","host_matching","``","and","``","static_host","``","parameters","were","added",".","..","versionadded",":",":","1.0","The","``","subdomain_matching","``","parameter","was","added",".","Subdomain","matching","needs","to","be","enabled","manually","now",".","Setting",":","data",":","`","SERVER_NAME","`","does","not","implicitly","enable","it",".",":","param","import_name",":","the","name","of","the","application","package",":","param","static_url_path",":","can","be","used","to","specify","a","different","path","for","the","static","files","on","the","web",".","Defaults","to","the","name","of","the","`","static_folder","`","folder",".",":","param","static_folder",":","The","folder","with","static","files","that","is","served","at","``","static_url_path","``",".","Relative","to","the","application","``","root_path","``","or","an","absolute","path",".","Defaults","to","``","'static","'","``",".",":","param","static_host",":","the","host","to","use","when","adding","the","static","route",".","Defaults","to","None",".","Required","when","using","``","host_matching=True","``","with","a","``","static_folder","``","configured",".",":","param","host_matching",":","set","``","url_map.host_matching","``","attribute",".","Defaults","to","False",".",":","param","subdomain_matching",":","consider","the","subdomain","relative","to",":","data",":","`","SERVER_NAME","`","when","matching","routes",".","Defaults","to","False",".",":","param","template_folder",":","the","folder","that","contains","the","templates","that","should","be","used","by","the","application",".","Defaults","to","``","'templates","'","``","folder","in","the","root","path","of","the","application",".",":","param","instance_path",":","An","alternative","instance","path","for","the","application",".","By","default","the","folder","``","'instance","'","``","next","to","the","package","or","module","is","assumed","to","be","the","instance","path",".",":","param","instance_relative_config",":","if","set","to","``","True","``","relative","filenames","for","loading","the","config","are","assumed","to","be","relative","to","the","instance","path","instead","of","the","application","root",".",":","param","root_path",":","The","path","to","the","root","of","the","application","files",".","This","should","only","be","set","manually","when","it","ca","n't","be","detected","automatically",",","such","as","for","namespace","packages","."]
docstr: A decorator that is used to register custom template test.
  You can specify a name for the test, otherwise the function
  name will be used. Example::
  
    @app.template_test()
    def is_prime(n):
        if n == 2:
            return True
        for i in range(2, int(math.ceil(math.sqrt(n))) + 1):
            if n % i == 0:
                return False
        return True
  
  .. versionadded:: 0.10
  
  :param name: the optional name of the test, otherwise the
               function name will be used.
docstr_tok: ["A","decorator","that","is","used","to","register","custom","template","test",".","You","can","specify","a","name","for","the","test",",","otherwise","the","function","name","will","be","used",".","Example",":",":","@","app.template_test","(",")","def","is_prime","(","n",")",":","if","n","==","2",":","return","True","for","i","in","range","(","2",",","int","(","math.ceil","(","math.sqrt","(","n",")",")",")","+","1",")",":","if","n","%","i","==","0",":","return","False","return","True","..","versionadded",":",":","0.10",":","param","name",":","the","optional","name","of","the","test",",","otherwise","the","function","name","will","be","used","."]
code: def template_test(
      self, name: str | None = None
  ) -> t.Callable[[T_template_test], T_template_test]:
      """A decorator that is used to register custom template test.
      You can specify a name for the test, otherwise the function
      name will be used. Example::
  
        @app.template_test()
        def is_prime(n):
            if n == 2:
                return True
            for i in range(2, int(math.ceil(math.sqrt(n))) + 1):
                if n % i == 0:
                    return False
            return True
  
      .. versionadded:: 0.10
  
      :param name: the optional name of the test, otherwise the
                   function name will be used.
      """
  
      def decorator(f: T_template_test) -> T_template_test:
          self.add_template_test(f, name=name)
          return f
  
      return decorator
  
imports: from __future__ import annotations
  import logging
  import os
  import sys
  import typing
  from datetime import timedelta
  from itertools import chain
  from werkzeug.exceptions import Aborter
  from werkzeug.exceptions import BadRequest
  from werkzeug.exceptions import BadRequestKeyError
  from werkzeug.routing import BuildError
  from werkzeug.routing import Map
  from werkzeug.routing import Rule
  from werkzeug.sansio.response import Response
  from werkzeug.utils import cached_property
  from werkzeug.utils import redirect
  from ..None import typing
  from ..config import Config
  from ..config import ConfigAttribute
  from ..ctx import _AppCtxGlobals
  from ..helpers import _split_blueprint_path
  from ..helpers import get_debug_flag
  from ..json.provider import DefaultJSONProvider
  from ..json.provider import JSONProvider
  from ..logging import create_logger
  from ..templating import DispatchingJinjaLoader
  from ..templating import Environment
  from .scaffold import _endpoint_from_view_func
  from .scaffold import find_package
  from .scaffold import Scaffold
  from .scaffold import setupmethod
label_desc: Use image node_id 19 for calling the App obj's underlying member method code with example usage: obj.template_test(name) and returns: decorator, f