6V=jڔddlmZddlZddlZddlZddlZddlmZddl m Z ddl m Z ddl m Z ddl mZddlmZdd lmZdd lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddl m!Z!ddl m"Z"ddl#m$Z$ddl#m%Z%ddlm&Z&ddl'm(Z(ddl'm)Z)ddl*m+Z+ddl*m,Z,ddl*m-Z-ddl*m.Z.ej/rdd l0mZ1ddl2m3Z3dd l2m4Z4dd!l5m6Z6ej7d"ej8#Z9ej7d$ej:#Z;ej7d%ej<#Z=ej7d&ej>#Z?ej7d'ej@#ZAd/d,ZBGd-d.e-ZCdS)0) annotationsN) timedelta)chain)Aborter) BadRequest)BadRequestKeyError) BuildError)Map)Rule)Response)cached_property)redirect)typing)Config)ConfigAttribute)_AppCtxGlobals)_split_blueprint_path)get_debug_flag)DefaultJSONProvider) JSONProvider create_loggerDispatchingJinjaLoader) Environment)_endpoint_from_view_func) find_package)Scaffold) setupmethod) FlaskClient)FlaskCliRunner) BlueprintT_shell_context_processor)bound T_teardownT_template_filterT_template_globalT_template_testvaluetimedelta | int | Nonereturntimedelta | NonecT|t|tr|St|S)N)seconds) isinstancer)r+s >C:\PYTHON\_runtimes\venv\Lib\site-packages\flask/sansio/app.py_make_timedeltar34s+ } 5)44} U # # ##c,eZdZUdZeZeZeZ e Z e e dZe ejeedfdZe edeZeZded< iZd ed <eZeZdZd ed <dZ d ed<d ed<ded< dodpfd% Z!dqd'Z"e#drd(Z$e#dsd*Z%e#dtd,Z&dtd-Z'dudvd0Z(dwd2Z)drd3Z*dxd5Z+dyd7Z,e-dzd8Z.e.j/d{d:Z.e0d|d?Z1d}dAZ2e0 d~ddHZ3e0 dddKZ4e0 dddNZ5e0 dddPZ6e0 dddRZ7e0 dddTZ8e0 dddVZ9e0ddXZ:e0ddZZ;dd`ZdddjZ?ddlZ@ddnZAxZBS)AppaThe 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. TESTINGN SECRET_KEYPERMANENT_SESSION_LIFETIME) get_converterztype[JSONProvider]json_provider_classdict[str, t.Any] jinja_optionsztype[FlaskClient] | Nonetest_client_classztype[FlaskCliRunner] | Nonetest_cli_runner_classdefault_configztype[Response]response_classstaticF templates import_namestrstatic_url_path str | None static_folderstr | os.PathLike[str] | None static_host host_matchingboolsubdomain_matchingtemplate_folder instance_pathinstance_relative_config root_pathr-Nonec  t||||| ||}n.tj|st d||_|| |_ | |_ | ||_ g|_g|_g|_i|_i|_|||_||_d|_dS)N)rDrHrFrNrQzWIf an instance path is provided it must be absolute. A relative path was given instead.)rKF)super__init__auto_find_instance_pathospathisabs ValueErrorrO make_configconfig make_aborteraborterr;jsonurl_build_error_handlersteardown_appcontext_funcsshell_context_processors blueprints extensions url_map_classurl_maprM_got_first_request) selfrDrFrHrJrKrMrNrOrPrQ __class__s r2rUz App.__init__s7 #'++       88::MM}-- 6 + &&'?@@ ((** "&":":4"@"@  2  %EG& QS%13-/")) )FF "4#(r4f_namec:|jrtd|ddS)NzThe setup method 'z' can no longer be called on the application. It has already handled its first request, any changes will not be applied consistently. Make sure all imports, decorators, functions, etc. needed to set up the application are done before running it.)rgAssertionError)rhrjs r2_check_setup_finishedzApp._check_setup_finisheds?  "  V   r4c|jdkrgttjddd}|dStjtj|dS|jS)a_The name of the application. This is usually the import name with the difference that it's guessed from the run file if the import name is main. This name is used as a display name when Flask needs the name of the application. It can be set and overridden to change the value. .. versionadded:: 0.8 __main____file__Nr)rDgetattrsysmodulesrWrXsplitextbasename)rhfns r2namezApp.namesh  z ) )$S[%7<< j99 9w||FEdi+B+B+BCCCr4rc t|S)aCreates the loader for the Jinja environment. Can be used to override just the loader and keeping the rest unchanged. It's discouraged to override this function. Instead one should override the :meth:`jinja_loader` function instead. The global loader dispatches between the loaders of the application and the individual blueprints. .. versionadded:: 0.7 rrzs r2create_global_jinja_loaderzApp.create_global_jinja_loader s&d+++r4filenamec4|dS|dS)aReturns ``True`` if autoescaping should be active for the given template name. If no template name is given, returns `True`. .. versionchanged:: 2.2 Autoescaping is now enabled by default for ``.svg`` files. .. versionadded:: 0.5 NT)z.htmlz.htmz.xmlz.xhtmlz.svg)endswith)rhrs r2select_jinja_autoescapezApp.select_jinja_autoescapes$  4  !LMMMr4c|jdS)aWhether debug mode is enabled. When using ``flask run`` to start the development server, an interactive debugger will be shown for unhandled exceptions, and the server will be reloaded when code changes. This maps to the :data:`DEBUG` config key. It may not behave as expected if set late. **Do not enable debug mode when deploying in production.** Default: ``False`` r)r\rzs r2debugz App.debug%s{7##r4r+cP||jd<|jd||j_dSdS)NrTEMPLATES_AUTO_RELOAD)r\r~ auto_reload)rhr+s r2rz App.debug2s4$ G ;. / 7).DN & & & 8 7r4 blueprintr$optionst.Anyc 2|||dS)axRegister a :class:`~flask.Blueprint` on the application. Keyword arguments passed to this method will override the defaults set on the blueprint. Calls the blueprint's :meth:`~flask.Blueprint.register` method after recording the blueprint in the application's :attr:`blueprints`. :param blueprint: The blueprint to register. :param url_prefix: Blueprint routes will be prefixed with this. :param subdomain: Blueprint routes will match on this subdomain. :param url_defaults: Blueprint routes will use these default values for view arguments. :param options: Additional keyword arguments are passed to :class:`~flask.blueprints.BlueprintSetupState`. They can be accessed in :meth:`~flask.Blueprint.record` callbacks. .. versionchanged:: 2.0.1 The ``name`` option can be used to change the (pre-dotted) name the blueprint is registered with. This allows the same blueprint to be registered multiple times with unique names for ``url_for``. .. versionadded:: 0.7 N)register)rhrrs r2register_blueprintzApp.register_blueprint9s 4 4)))))r4t.ValuesView[Blueprint]c4|jS)zhIterates over all blueprints by the order they were registered. .. versionadded:: 0.11 )rcvaluesrzs r2iter_blueprintszApp.iter_blueprintsUs %%'''r4ruleendpoint view_funcft.RouteCallable | Noneprovide_automatic_options bool | Nonec |t|}||d<|dd}|t|ddpd}t|trt dd|D}t t|dd}|t|dd}|+d |vr%|jd rd }|d nd }||z}|j |fd|i|}||_ |j ||@|j |} | | |krtd |||j |<dSdS)Nrmethods)GETzYAllowed methods must be a list of strings, for example: @app.route(..., methods=["POST"])c6h|]}|S)upper).0items r2 z#App.add_url_rule..ts 444D4::<<444r4required_methodsrrOPTIONSPROVIDE_AUTOMATIC_OPTIONSTFzDView function mapping is overwriting an existing endpoint function: )rpoprqr1rE TypeErrorsetr\addurl_rule_classrrfview_functionsgetrl) rhrrrrrrrrule_objold_funcs r2 add_url_rulezApp.add_url_rule\s  / ::H& ++i.. ?iD99EXG gs # # > 54G444&).decorator!  $ $QT $ 2 2 2Hr4)rr(r-r(rrhrwrs`` r2template_filterzApp.template_filters/        r4rft.TemplateFilterCallablec2||jj|p|j<dS)zRegister a custom template filter. Works exactly like the :meth:`template_filter` decorator. :param name: the optional name of the filter, otherwise the function name will be used. N)r~filters__name__rhrrws r2rzApp.add_template_filters 67t1qz222r4.t.Callable[[T_template_test], T_template_test]cdfd }|S)aSA 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. rr*r-c6||Sr)add_template_testrs r2rz$App.template_test..decorators!  " "14 " 0 0 0Hr4)rr*r-r*rrs`` r2 template_testzApp.template_tests/.       r4ft.TemplateTestCallablec2||jj|p|j<dS)zRegister a custom template test. Works exactly like the :meth:`template_test` decorator. .. versionadded:: 0.10 :param name: the optional name of the test, otherwise the function name will be used. N)r~testsrrs r2rzApp.add_template_tests 45T/QZ000r42t.Callable[[T_template_global], T_template_global]cdfd }|S)aA decorator that is used to register a custom template global function. You can specify a name for the global function, otherwise the function name will be used. Example:: @app.template_global() def double(n): return 2 * n .. versionadded:: 0.10 :param name: the optional name of the global function, otherwise the function name will be used. rr)r-c6||Sr)add_template_globalrs r2rz&App.template_global..decoratorrr4)rr)r-r)rrs`` r2template_globalzApp.template_globals/$       r4ft.TemplateGlobalCallablec2||jj|p|j<dS)aRegister a custom template global function. Works exactly like the :meth:`template_global` decorator. .. versionadded:: 0.10 :param name: the optional name of the global function, otherwise the function name will be used. N)r~globalsrrs r2rzApp.add_template_globals 67t1qz222r4r'c:|j||S)aRegisters a function to be called when the application context is popped. The application context is typically popped after the request context for each request, at the end of CLI commands, or after a manually pushed context ends. .. code-block:: python with app.app_context(): ... When the ``with`` block exits (or ``ctx.pop()`` is called), the teardown functions are called just before the app context is made inactive. Since a request context typically also manages an application context it would also be called when you pop a request context. When a teardown function was called because of an unhandled exception it will be passed an error object. If an :meth:`errorhandler` is registered, it will handle the exception and the teardown will not receive it. Teardown functions must avoid raising exceptions. If they execute code that might fail they must surround that code with a ``try``/``except`` block and log any errors. The return values of teardown functions are ignored. .. versionadded:: 0.9 )raappendrhrs r2teardown_appcontextzApp.teardown_appcontext s > &--a000r4r%c:|j||S)zVRegisters a shell context processor function. .. versionadded:: 0.11 )rbrrs r2shell_context_processorzApp.shell_context_processor,s  %,,Q///r4e Exceptionrc list[str]ft.ErrorHandlerCallable | Nonec|t|\}}g|dR}||dfndD]F}|D]A}|j||}|s|jD]!} || } | | cccS"BGdS)a(Return a registered error handler for an exception in this order: blueprint handler for a specific code, app handler for a specific code, blueprint handler for an exception class, app handler for an exception class, or ``None`` if a suitable handler is not found. Nr)_get_exc_class_and_codetypeerror_handler_spec__mro__r) rhrrc exc_classcodenamescrw handler_mapclshandlers r2_find_error_handlerzApp._find_error_handler7s66tAww?? 4#*#d##!%!1$w ' 'A ' '"5d;A> "$,''C)ooc22G*&+' 'tr4c|jdrdS|jd}||jrt|trdS|rt|tSdS)aChecks if an HTTP exception should be trapped or not. By default this will return ``False`` for all exceptions except for a bad request key error if ``TRAP_BAD_REQUEST_ERRORS`` is set to ``True``. It also returns ``True`` if ``TRAP_HTTP_EXCEPTIONS`` is set to ``True``. This is called for all HTTP exceptions raised by a view function. If it returns ``True`` for any exception the error handler for this exception is not called and it shows up as regular exception in the traceback. This is helpful for debugging implicitly raised HTTP exceptions. .. versionchanged:: 1.0 Bad request errors are not trapped by default in debug mode. .. versionadded:: 0.8 TRAP_HTTP_EXCEPTIONSTTRAP_BAD_REQUEST_ERRORSNF)r\rr1rr)rhrtrap_bad_requests r2trap_http_exceptionzApp.trap_http_exceptionPsp" ;- . 4;'@A  $  %1011 %4  -a,, ,ur4errorBaseException | NonecdS)a This is called to figure out if an error should be ignored or not as far as the teardown system is concerned. If this function returns ``True`` then the teardown handlers will not be passed the error. .. versionadded:: 0.10 Fr)rhrs r2should_ignore_errorzApp.should_ignore_errorss ur4.locationrint BaseResponsec0t|||jS)aVCreate a redirect response object. This is called by :func:`flask.redirect`, and can be called directly as well. :param location: The URL to redirect to. :param code: The status code for the redirect. .. versionadded:: 2.2 Moved from ``flask.redirect``, which calls this method. )rr ) _wz_redirectrA)rhrrs r2rz App.redirect}s' (    r4rc d}d|vrCt|tt|dd}|D]'}||jvr|j|D]}|||(dS)zInjects the URL defaults for the given endpoint directly into the values dictionary passed. This is used internally and automatically called on URL building. .. versionadded:: 0.7 r.rN)rreversedr rpartitionurl_default_functions)rhrrrrwfuncs r2inject_url_defaultszApp.inject_url_defaultss)0 (??x 5h6I6I#6N6Nq6Q R RSSE + +Dt111 6t<++DD6**** + +r4r c|jD]/} ||||}||cS#t$r }|}Yd}~(d}~wwxYw|tjdur|)aCalled by :meth:`.url_for` if a :exc:`~werkzeug.routing.BuildError` was raised. If this returns a value, it will be returned by ``url_for``, otherwise the error will be re-raised. Each function in :attr:`url_build_error_handlers` is called with ``error``, ``endpoint`` and ``values``. If a function returns ``None`` or raises a ``BuildError``, it is skipped. Otherwise, its return value is returned by ``url_for``. :param error: The active ``BuildError`` being handled. :param endpoint: The endpoint being built. :param values: The keyword arguments passed to ``url_for``. Nr)r`r rrexc_info)rhrrrrrvrs r2handle_url_build_errorzApp.handle_url_build_errors"4  G WUHf55 >III"      CLNN1% % %  s  505) NrBNFFrCNFN)rDrErFrGrHrIrJrGrKrLrMrLrNrIrOrGrPrLrQrGr-rR)rjrEr-rR)r-rE)r-rx)r-r)F)rrLr-r)r-r)r-r)rrGr-rL)r-rL)r+rLr-rR)rr$rrr-rR)r-r)NNN) rrErrGrrrrrrr-rRr)rwrGr-r)rrrwrGr-rR)rwrGr-r)rrrwrGr-rR)rwrGr-r)rrrwrGr-rR)rr'r-r')rr%r-r%)rrrcrr-r)rrr-rL)rrr-rL)r)rrErrr-r)rrErr<r-rR)rr rrErr<r-rE)Cr __module__ __qualname____doc__rrrjinja_environmentrapp_ctx_globals_classrrrrLtestingtUnionrEbytes secret_keyrr3permanent_session_lifetimerr;__annotations__r=r rr rer>r?rUrmr rwr{r~r}r[r]rVrrpropertyrsetterr!rrrrrrrrrrrrrrrr r __classcell__)ris@r2r6r6;s^^PM $ +L$od#I..G<eT)9!:;LIIJ"<!;$%""" /BAAAA (')M(((( N M 376666:>====$$$$"""" '+7?"&##(9D$(). $A(A(A(A(A(A(A(F       _ ###_#4///_/$$$$66666 $ $ $ $ D D D D , , , , N N N N $ $ $X $ \///\/ ***[*6(((( $-115 86868686[86t!%[*?C 7 7 7 7[ 7!%[8=A 5 5 5 5[ 5!%[.?C 7 7 7 7[ 7[B[2!!!!F     $++++*        r4r6)r+r,r-r.)D __future__rloggingrWrrrrdatetimer itertoolsrwerkzeug.exceptionsrrrwerkzeug.routingr r r werkzeug.sansio.responser werkzeug.utilsr rrftr\rrctxrhelpersrr json.providerrrr templatingrrscaffoldrrr r! TYPE_CHECKINGwerkzeug.wrappersrrr"r#rcr$TypeVarShellContextProcessorCallabler%TeardownCallabler'TemplateFilterCallabler(TemplateGlobalCallabler)TemplateTestCallabler*r3r6rr4r2r8sB"""""" ''''''******222222'''''' !!!!!!------******333333$$$$$$ ++++++$$$$$$//////((((((######//////$$$$$$......""""""!!!!!!?&::::::%%%%%%((((((%%%%%%%AIr'GQY|2+> ? ? ? AI19RSSSAI19RSSS!)-R5LMMM$$$$IIIII(IIIIIr4