Files
old-parkingkoncept/parkingkonceptvenv/lib/python3.7/site-packages/flask/__pycache__/app.cpython-37.pyc

1186 lines
73 KiB
Plaintext
Raw Normal View History

2019-11-17 12:44:16 +01:00
B
<00>/<2F>]<00>@s<>dZddlZddlZddlZddlmZddlmZddlm Z ddl
m Z ddl m Z ddl mZdd lmZdd
lmZdd lmZdd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddl!m"Z"ddl!m#Z#ddl!m$Z$ddl!m%Z%ddl&m'Z'ddl&m(Z(ddl)m*Z*ddl)m+Z+dd l)m,Z,dd!l-m.Z.dd"l-m/Z/dd#l-m0Z0dd$l-m1Z1dd%l2m3Z3dd&l2m4Z4dd'l2m5Z5dd(l2m6Z6dd)l2m7Z7dd*l2m8Z8dd+l2m9Z9dd,l2m:Z:dd-l2m;Z;dd.l m<Z<dd/l=m>Z>dd0l?m@Z@dd1lAmBZBdd2lAmCZCdd3lAmDZDdd4lAmEZEdd5lAmFZFdd6lGmHZHdd7lGmIZIdd8lGmJZJdd9lKmLZLdd:lKmMZMeN<65>ZOd;d<<3C>ZPd=d><3E>ZQGd?d@<40>d@e4<65>ZRdS)Az<41>
flask.app
~~~~~~~~~
This module implements the central WSGI application object.
:copyright: 2010 Pallets
:license: BSD-3-Clause
<EFBFBD>N)<01> timedelta)<01>update_wrapper)<01>chain)<01>Lock)<01>Headers)<01> ImmutableDict)<01>
BadRequest)<01>BadRequestKeyError)<01>default_exceptions)<01> HTTPException)<01>InternalServerError)<01>MethodNotAllowed)<01>
BuildError)<01>Map)<01>RequestRedirect)<01>RoutingException)<01>Rule)<01> BaseResponse<73>)<01>cli)<01>json)<01> integer_types)<01>reraise)<01> string_types)<01> text_type)<01>Config)<01>ConfigAttribute)<01>_AppCtxGlobals)<01>
AppContext)<01>RequestContext)<01>_request_ctx_stack)<01>g)<01>request)<01>session)<01>_endpoint_from_view_func)<01>_PackageBoundObject)<01> find_package)<01>get_debug_flag)<01>get_env)<01>get_flashed_messages)<01>get_load_dotenv)<01>locked_cached_property)<01>url_for)<01>jsonify)<01> create_logger)<01>SecureCookieSessionInterface)<01>appcontext_tearing_down)<01>got_request_exception)<01>request_finished)<01>request_started)<01>request_tearing_down)<01>_default_template_ctx_processor)<01>DispatchingJinjaLoader)<01> Environment)<01>Request)<01>ResponsecCst|t<01>st|d<01>S|S)N)<01>seconds)<02>
isinstancer)<01>value<75>r=<00>,/tmp/pip-install-c3kgu56x/Flask/flask/app.py<70>_make_timedeltaLs

r?cs<00>fdd<02>}t|<01><00>S)zkWraps a method so that it performs a check in debug mode if the
first request was already handled.
cs$|jr|jrtd<01><01><01>|f|<01>|<02>S)NamA setup function was called after the first request was handled. This usually indicates a bug in the application where a module was not imported and decorators or other functionality was called too late.
To fix this make sure to import all your view modules, database models and everything related at a central place before the application starts serving requests.)<03>debug<75>_got_first_request<73>AssertionError)<03>self<6C>args<67>kwargs)<01>fr=r><00> wrapper_funcWs z!setupmethod.<locals>.wrapper_func)r)rFrGr=)rFr><00> setupmethodRs rHc@s<>eZdZdZeZeZeZ e
Z e Z ed<02>Zed<03>Zed<04>Zeded<06>Zeded<06>Zed<08>ZejZejZd d
d giZed d d d d d edd<0F>d d ddd d dd d dd edd<14>d d d dddd dd dd<18><1D>ZeZ e!Z"d Z#d Z$e%<25>Z&d Z'd Z(d Z)d<>dd<1C>Z*e+dd<1E><00>Z,e-dd <20><00>Z.e-d!d"<22><00>Z/e+d#d$<24><00>Z0e+d%d&<26><00>Z1e-d'd(<28><00>Z2d<32>d)d*<2A>Z3d+d,<2C>Z4d<34>d.d/<2F>Z5e-d0d1<64><00>Z6e6j7d2d1<64><00>Z6d3d4<64>Z8d5d6<64>Z9d7d8<64>Z:d9d:<3A>Z;d;d<<3C>Z<ed=<3D>Z=e-d>d?<3F><00>Z>e>j7d@d?<3F><00>Z>d<>dAdB<64>Z?d<>dCdD<64>Z@dEdF<64>ZAdGdH<64>ZBdIdJ<64>ZCdKdL<64>ZDeEdMdN<64><00>ZFdOdP<64>ZGeEd<45>dQdR<64><01>ZHdSdT<64>ZIeEdUdV<64><00>ZJeKdWdX<64><00>ZLeEdYdZ<64><00>ZMeEd[d\<5C><00>ZNeEd]d^<5E><00>ZOeEd<45>d_d`<60><01>ZPeEd<45>dadb<64><01>ZQeEd<45>dcdd<64><01>ZReEd<45>dedf<64><01>ZSeEd<45>dgdh<64><01>ZTeEd<45>didj<64><01>ZUeEdkdl<64><00>ZVeEdmdn<64><00>ZWeEdodp<64><00>ZXeEdqdr<64><00>ZYeEdsdt<64><00>ZZeEdudv<64><00>Z[eEdwdx<64><00>Z\eEdydz<64><00>Z]eEd{d|<7C><00>Z^d}d~<7E>Z_dd<7F><64>Z`d<>d<EFBFBD><64>Zad<61>d<EFBFBD><64>Zbd<62>d<EFBFBD><64>Zcd<63>d<EFBFBD><64>Zdd<64>d<EFBFBD><64>Zed<65>d<EFBFBD><64>Zfd<66>d<EFBFBD><64>Zgd<67>d<EFBFBD>d<EFBFBD><64>Zhd<68>d<EFBFBD><64>Zid<69>d<EFBFBD><64>Zjd<6A>d<EFBFBD><64>Zkd<6B>d<EFBFBD><64>Zld<6C>d<EFBFBD><64>Zmd<6D>d<EFBFBD><64>Znd<6E>d<EFBFBD><64>Zod<6F>d<EFBFBD><64>Zpd<70>d<EFBFBD><64>Zqerfd<>d<EFBFBD><64>Zserfd<>d<EFBFBD><64>Ztd<74>d<EFBFBD><64>Zud<75>d<EFBFBD><64>Zvd<76>d<EFBFBD><64>Zwd<77>d<EFBFBD><64>Zxd<78>d<EFBFBD><64>Zyd<79>d<EFBFBD><64>Zzd S)<29><>Flaska<6B>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 should be served
at `static_url_path`. Defaults to the ``'static'``
folder in the root path of the application.
: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: Flask by default will automatically calculate the path
to the root of the application. In certain situations
this cannot be achieved (for instance if the package
is a Python 3 namespace package) and needs to be
manually defined.
<20>TESTING<4E>
SECRET_KEY<EFBFBD>SESSION_COOKIE_NAME<4D>PERMANENT_SESSION_LIFETIME)Z get_converter<65>SEND_FILE_MAX_AGE_DEFAULT<4C>USE_X_SENDFILE<4C>
extensionszjinja2.ext.autoescapezjinja2.ext.with_NF<4E>)<01>days<79>/r#T<> )<01>hours<72>httpzapplication/jsoni<6E>)<1D>ENV<4E>DEBUGrJ<00>PROPAGATE_EXCEPTIONS<4E>PRESERVE_CONTEXT_ON_EXCEPTIONrKrMrO<00> SERVER_NAME<4D>APPLICATION_ROOTrLZSESSION_COOKIE_DOMAINZSESSION_COOKIE_PATHZSESSION_COOKIE_HTTPONLYZSESSION_COOKIE_SECUREZSESSION_COOKIE_SAMESITEZSESSION_REFRESH_EACH_REQUESTZMAX_CONTENT_LENGTHrN<00>TRAP_BAD_REQUEST_ERRORS<52>TRAP_HTTP_EXCEPTIONSZEXPLAIN_TEMPLATE_LOADING<4E>PREFERRED_URL_SCHEMEZ JSON_AS_ASCIIZJSON_SORT_KEYSZJSONIFY_PRETTYPRINT_REGULARZJSONIFY_MIMETYPE<50>TEMPLATES_AUTO_RELOADZMAX_COOKIE_SIZE<5A>static<69> templatesc Cs tj||||
d<01>||_||_|dkr0|<00><04>}ntj<06>|<08>sDtd<02><01>||_ |<00>
| <09>|_ i|_ i|_ g|_i|_g|_i|_i|_g|_i|_i|_dtgi|_g|_i|_g|_i|_|<00><1C>|_||j_||_d|_ t!<21>|_"|j#<23>rt$|<04>|ks<>t%d<04><01>|j&|jdd||j'd<07>|j(|j)_(dS)N)<02>template_folder<65> root_pathzWIf an instance path is provided it must be absolute. A relative path was given instead.Fz-Invalid static_host/host_matching combinationz/<path:filename>ra)<03>endpoint<6E>host<73> view_func)*r%<00>__init__<5F>static_url_path<74> static_folder<65>auto_find_instance_path<74>os<6F>path<74>isabs<62>
ValueError<EFBFBD> instance_path<74> make_config<69>config<69>view_functions<6E>error_handler_spec<65>url_build_error_handlers<72>before_request_funcs<63>before_first_request_funcs<63>after_request_funcs<63>teardown_request_funcs<63>teardown_appcontext_funcs<63>url_value_preprocessors<72>url_default_functionsr5<00>template_context_processors<72>shell_context_processors<72>
blueprints<EFBFBD>_blueprint_orderrP<00> url_map_class<73>url_map<61> host_matching<6E>subdomain_matchingrAr<00>_before_request_lockZhas_static_folder<65>boolrB<00> add_url_ruleZsend_static_file<6C>namer) rC<00> import_namerirjZ static_hostr<74>r<>rcrpZinstance_relative_configrdr=r=r>rh<00>sP 
        

zFlask.__init__cCsF|jdkr@ttjddd<03>}|dkr(dStj<05>tj<05>|<01><01>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
<20>__main__<5F>__file__Nr)r<><00>getattr<74>sys<79>modulesrlrm<00>splitext<78>basename)rC<00>fnr=r=r>r<>ds
z
Flask.namecCs"|jd}|dk r|S|jp |jS)z<>Returns the value of the ``PROPAGATE_EXCEPTIONS`` configuration
value in case it's set, otherwise a sensible default is returned.
.. versionadded:: 0.7
rYN)rr<00>testingr@)rC<00>rvr=r=r><00>propagate_exceptionsus
zFlask.propagate_exceptionscCs|jd}|dk r|S|jS)z<>Returns the value of the ``PRESERVE_CONTEXT_ON_EXCEPTION``
configuration value in case it's set, otherwise a sensible default
is returned.
.. versionadded:: 0.7
rZN)rrr@)rCr<>r=r=r><00>preserve_context_on_exception<6F>s
z#Flask.preserve_context_on_exceptioncCst|<00>S)a<>A standard Python :class:`~logging.Logger` for the app, with
the same name as :attr:`name`.
In debug mode, the logger's :attr:`~logging.Logger.level` will
be set to :data:`~logging.DEBUG`.
If there are no handlers configured, a default handler will be
added. See :doc:`/logging` for more information.
.. versionchanged:: 1.1.0
The logger takes the same name as :attr:`name` rather than
hard-coding ``"flask.app"``.
.. versionchanged:: 1.0.0
Behavior was simplified. The logger is always named
``"flask.app"``. The level is only set during configuration,
it doesn't check ``app.debug`` each time. Only one format is
used, not different ones depending on ``app.debug``. No
handlers are removed, and a handler is only added if no
handlers are already configured.
.. versionadded:: 0.3
)r.)rCr=r=r><00>logger<65>sz Flask.loggercCs|<00><00>S)z<>The Jinja environment used to load templates.
The environment is created the first time this property is
accessed. Changing :attr:`jinja_options` after that will have no
effect.
)<01>create_jinja_environment)rCr=r=r><00> jinja_env<6E>szFlask.jinja_envcCs|jS)z<>This attribute is set to ``True`` if the application started
handling the first request.
.. versionadded:: 0.8
)rA)rCr=r=r><00>got_first_request<73>szFlask.got_first_requestcCs:|j}|r|j}t|j<03>}t<04>|d<t<05>|d<|<00>||<03>S)adUsed to create the config attribute by the Flask constructor.
The `instance_relative` parameter is passed in from the constructor
of Flask (there named `instance_relative_config`) and indicates if
the config should be relative to the instance path or the root path
of the application.
.. versionadded:: 0.8
rWrX)rdrp<00>dict<63>default_configr(r'<00> config_class)rCZinstance_relativerd<00>defaultsr=r=r>rq<00>s 


zFlask.make_configcCs:t|j<01>\}}|dkr$tj<03>|d<02>Stj<03>|d|jd<00>S)aTries to locate the instance path if it was not provided to the
constructor of the application class. It will basically calculate
the path to a folder named ``instance`` next to your main file or
the package.
.. versionadded:: 0.8
N<>instance<63>varz -instance)r&r<>rlrm<00>joinr<6E>)rC<00>prefixZ package_pathr=r=r>rk<00>szFlask.auto_find_instance_path<74>rbcCsttj<02>|j|<01>|<02>S)a<>Opens a resource from the application's instance folder
(:attr:`instance_path`). Otherwise works like
:meth:`open_resource`. Instance resources can also be opened for
writing.
:param resource: the name of the resource. To access resources within
subfolders use forward slashes as separator.
:param mode: resource file opening mode, default is 'rb'.
)<05>openrlrmr<>rp)rC<00>resource<63>moder=r=r><00>open_instance_resource<63>s
zFlask.open_instance_resourcecCs|jd}|dk r|S|jS)amReload templates when they are changed. Used by
:meth:`create_jinja_environment`.
This attribute can be configured with :data:`TEMPLATES_AUTO_RELOAD`. If
not set, it will be enabled in debug mode.
.. versionadded:: 1.0
This property was added but the underlying config and behavior
already existed.
r`N)rrr@)rCr<>r=r=r><00>templates_auto_reload<61>s
zFlask.templates_auto_reloadcCs||jd<dS)Nr`)rr)rCr<r=r=r>r<><00>scCsft|j<01>}d|kr|j|d<d|kr.|j|d<|j|f|<01>}|jjtt|j t
t t d<03>t j|jd<|S)a<>Create the Jinja environment based on :attr:`jinja_options`
and the various Jinja-related methods of the app. Changing
:attr:`jinja_options` after this will have no effect. Also adds
Flask-related globals and filters to the environment.
.. versionchanged:: 0.11
``Environment.auto_reload`` set in accordance with
``TEMPLATES_AUTO_RELOAD`` configuration option.
.. versionadded:: 0.5
Z
autoescape<EFBFBD> auto_reload)r,r)rrr"r#r!Ztojson)r<><00> jinja_options<6E>select_jinja_autoescaper<65><00>jinja_environment<6E>globals<6C>updater,r)rrr"r#r!rZ tojson_filter<65>filters)rC<00>optionsr<73>r=r=r>r<><00>s


 zFlask.create_jinja_environmentcCst|<00>S)a<>Creates the loader for the Jinja2 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
)r6)rCr=r=r><00>create_global_jinja_loaders z Flask.create_global_jinja_loadercCs|dkr dS|<01>d<03>S)z<>Returns ``True`` if autoescaping should be active for the given
template name. If no template name is given, returns `True`.
.. versionadded:: 0.5
NT)z.htmlz.htmz.xmlz.xhtml)<01>endswith)rC<00>filenamer=r=r>r<>)szFlask.select_jinja_autoescapecCsr|jd}tj}|dk rB|jj}|dk rB||jkrBt||j|<00>}|<01><06>}x|D]}|<01>|<06><00>qPW|<01>|<05>dS)aUpdate the template context with some commonly used variables.
This injects request, session, config and g into the template
context as well as everything template context processors want
to inject. Note that the as of Flask 0.6, the original values
in the context will not be overridden if a context processor
decides to return a value with the same key.
:param context: the context as a dictionary that is updated in place
to add extra variables.
N)r}r <00>topr"<00> blueprintr<00>copyr<79>)rC<00>context<78>funcsZreqctx<74>bpZorig_ctx<74>funcr=r=r><00>update_template_context3s

zFlask.update_template_contextcCs*|td<01>}x|jD]}|<01>|<02><00>qW|S)z<>Returns the shell context for an interactive shell for this
application. This runs all the registered shell context
processors.
.. versionadded:: 0.11
)Zappr!)r!r~r<>)rCr<><00> processorr=r=r><00>make_shell_contextLs
 zFlask.make_shell_contextrWcCs
|jdS)avWhether 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. This is
enabled when :attr:`env` is ``'development'`` and is overridden
by the ``FLASK_DEBUG`` environment variable. It may not behave as
expected if set in code.
**Do not enable debug mode when deploying in production.**
Default: ``True`` if :attr:`env` is ``'development'``, or
``False`` otherwise.
rX)rr)rCr=r=r>r@csz Flask.debugcCs||jd<|j|j_dS)NrX)rrr<>r<>r<>)rCr<r=r=r>r@ts
cKs:tj<01>d<01>dkr&ddlm}|<06>dSt|<04>rdt<06><07>dtjkrRt<08>|_ t
<EFBFBD>|_ ndtjkrdt
<EFBFBD>|_ |dk rvt |<03>|_ d}d }|j <0A>d
<EFBFBD>} d \}
} | r<>| <09>d <0C>\}
} } |p<>|
p<EFBFBD>|}ttd d<0E>|| fD<00>|<08><02>}|<05>d|j <0B>|<05>d|j <0B>|<05>dd<12>t<06>|j |j |jd<13>ddlm} z| |||f|<05>Wdd|_XdS)a Runs the application on a local development server.
Do not use ``run()`` in a production setting. It is not intended to
meet security and performance requirements for a production server.
Instead, see :ref:`deployment` for WSGI server recommendations.
If the :attr:`debug` flag is set the server will automatically reload
for code changes and show a debugger in case an exception happened.
If you want to run the application in debug mode, but disable the
code execution on the interactive debugger, you can pass
``use_evalex=False`` as parameter. This will keep the debugger's
traceback screen active, but disable code execution.
It is not recommended to use this function for development with
automatic reloading as this is badly supported. Instead you should
be using the :command:`flask` command line script's ``run`` support.
.. admonition:: Keep in Mind
Flask will suppress any server error with a generic error page
unless it is in debug mode. As such to enable just the
interactive debugger without the code reloading, you have to
invoke :meth:`run` with ``debug=True`` and ``use_reloader=False``.
Setting ``use_debugger`` to ``True`` without being in debug mode
won't catch any exceptions because there won't be any to
catch.
:param host: the hostname to listen on. Set this to ``'0.0.0.0'`` to
have the server available externally as well. Defaults to
``'127.0.0.1'`` or the host in the ``SERVER_NAME`` config variable
if present.
:param port: the port of the webserver. Defaults to ``5000`` or the
port defined in the ``SERVER_NAME`` config variable if present.
:param debug: if given, enable or disable debug mode. See
:attr:`debug`.
:param load_dotenv: Load the nearest :file:`.env` and :file:`.flaskenv`
files to set environment variables. Will also change the working
directory to the directory containing the first file found.
:param options: the options to be forwarded to the underlying Werkzeug
server. See :func:`werkzeug.serving.run_simple` for more
information.
.. versionchanged:: 1.0
If installed, python-dotenv will be used to load environment
variables from :file:`.env` and :file:`.flaskenv` files.
If set, the :envvar:`FLASK_ENV` and :envvar:`FLASK_DEBUG`
environment variables will override :attr:`env` and
:attr:`debug`.
Threaded mode is enabled by default.
.. versionchanged:: 0.10
The default port is now picked from the ``SERVER_NAME``
variable.
ZFLASK_RUN_FROM_CLI<4C>truer)<01>explain_ignored_app_runNZ FLASK_ENVZ FLASK_DEBUGz 127.0.0.1i<EFBFBD>r[)NN<4E>:css|]}|dk r|VqdS)Nr=)<02>.0<EFBFBD>pr=r=r><00> <genexpr><3E>szFlask.run.<locals>.<genexpr>Z use_reloaderZ use_debuggerZthreadedTFr)<01>
run_simple)rl<00>environ<6F>get<65> debughelpersr<73>r*r<00> load_dotenvr(<00>envr'r@r<>rr<00> partition<6F>int<6E>next<78>
setdefaultZshow_server_bannerr<72>Zwerkzeug.servingr<67>rA)rCrf<00>portr@r<>r<>r<>Z_hostZ_port<72> server_nameZsn_hostZsn_port<72>_r<5F>r=r=r><00>runys:< 



    z Flask.runcKs2|j}|dkrddlm}|||jfd|i|<02><02>S)a<>Creates a test client for this application. For information
about unit testing head over to :ref:`testing`.
Note that if you are testing for assertions or exceptions in your
application code, you must set ``app.testing = True`` in order for the
exceptions to propagate to the test client. Otherwise, the exception
will be handled by the application (not visible to the test client) and
the only indication of an AssertionError or other exception will be a
500 status code response to the test client. See the :attr:`testing`
attribute. For example::
app.testing = True
client = app.test_client()
The test client can be used in a ``with`` block to defer the closing down
of the context until the end of the ``with`` block. This is useful if
you want to access the context locals for testing::
with app.test_client() as c:
rv = c.get('/?vodka=42')
assert request.args['vodka'] == '42'
Additionally, you may pass optional keyword arguments that will then
be passed to the application's :attr:`test_client_class` constructor.
For example::
from flask.testing import FlaskClient
class CustomClient(FlaskClient):
def __init__(self, *args, **kwargs):
self._authentication = kwargs.pop("authentication")
super(CustomClient,self).__init__( *args, **kwargs)
app.test_client_class = CustomClient
client = app.test_client(authentication='Basic ....')
See :class:`~flask.testing.FlaskClient` for more information.
.. versionchanged:: 0.4
added support for ``with`` block usage for the client.
.. versionadded:: 0.7
The `use_cookies` parameter was added as well as the ability
to override the client to be used by setting the
:attr:`test_client_class` attribute.
.. versionchanged:: 0.11
Added `**kwargs` to support passing additional keyword arguments to
the constructor of :attr:`test_client_class`.
Nr)<01> FlaskClient<6E> use_cookies)<04>test_client_classr<73>r<><00>response_class)rCr<>rE<00>clsr=r=r><00> test_client<6E>s3 zFlask.test_clientcKs&|j}|dkrddlm}||f|<01>S)a-Create a CLI runner for testing CLI commands.
See :ref:`testing-cli`.
Returns an instance of :attr:`test_cli_runner_class`, by default
:class:`~flask.testing.FlaskCliRunner`. The Flask app object is
passed as the first argument.
.. versionadded:: 1.0
Nr)<01>FlaskCliRunner)<03>test_cli_runner_classr<73>r<>)rCrEr<>r=r=r><00>test_cli_runners
 zFlask.test_cli_runnercCst<00>td<01><01>|j<03>||<01>S)a<>Creates or opens a new session. Default implementation stores all
session data in a signed cookie. This requires that the
:attr:`secret_key` is set. Instead of overriding this method
we recommend replacing the :class:`session_interface`.
.. deprecated: 1.0
Will be removed in 1.1. Use ``session_interface.open_session``
instead.
:param request: an instance of :attr:`request_class`.
zf"open_session" is deprecated and will be removed in 1.1. Use "session_interface.open_session" instead.)<05>warnings<67>warn<72>DeprecationWarning<6E>session_interface<63> open_session)rCr"r=r=r>r<>.s zFlask.open_sessioncCst<00>td<01><01>|j<03>|||<02>S)a2Saves the session if it needs updates. For the default
implementation, check :meth:`open_session`. Instead of overriding this
method we recommend replacing the :class:`session_interface`.
.. deprecated: 1.0
Will be removed in 1.1. Use ``session_interface.save_session``
instead.
:param session: the session to be saved (a
:class:`~werkzeug.contrib.securecookie.SecureCookie`
object)
:param response: an instance of :attr:`response_class`
zf"save_session" is deprecated and will be removed in 1.1. Use "session_interface.save_session" instead.)r<>r<>r<>r<><00> save_session)rCr#<00>responser=r=r>r<>CszFlask.save_sessioncCst<00>td<01><01>|j<03>|<00>S)a7Creates a new instance of a missing session. Instead of overriding
this method we recommend replacing the :class:`session_interface`.
.. deprecated: 1.0
Will be removed in 1.1. Use ``session_interface.make_null_session``
instead.
.. versionadded:: 0.7
zp"make_null_session" is deprecated and will be removed in 1.1. Use "session_interface.make_null_session" instead.)r<>r<>r<>r<><00>make_null_session)rCr=r=r>r<>Zs zFlask.make_null_sessioncKsld}|j|jkr>|j|j|ksZtd||j|j|jf<00><01>n||j|j<|j<03>|<01>d}|<01>|||<03>dS)aaRegister 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.
.. versionadded:: 0.7
Fz<46>A name collision occurred between blueprints %r and %r. Both share the same name "%s". Blueprints that are created on the fly need unique names.TN)r<>rrBr<><00>append<6E>register)rCr<>r<>Zfirst_registrationr=r=r><00>register_blueprintms   zFlask.register_blueprintcCs
t|j<01>S)zhIterates over all blueprints by the order they were registered.
.. versionadded:: 0.11
)<02>iterr<72>)rCr=r=r><00>iter_blueprints<74>szFlask.iter_blueprintsc Ks|dkrt|<03>}||d<|<05>dd<01>}|dkr<t|dd<01>p:d}t|t<04>rNtd<05><01>tdd<07>|D<00><01>}tt|dd <09><03>}|dkr<>t|d
d<01>}|dkr<>d |kr<>d }|<07>d <0B>nd }||O}|j|fd|i|<05><02>}||_ |j
<EFBFBD>|<01>|dk <09>r|j <0B> |<02>}|dk <09>r||k<03>rt d|<00><01>||j |<dS)a<>Connects a URL rule. Works exactly like the :meth:`route`
decorator. If a view_func is provided it will be registered with the
endpoint.
Basically this example::
@app.route('/')
def index():
pass
Is equivalent to the following::
def index():
pass
app.add_url_rule('/', 'index', index)
If the view_func is not provided you will need to connect the endpoint
to a view function like so::
app.view_functions['index'] = index
Internally :meth:`route` invokes :meth:`add_url_rule` so if you want
to customize the behavior via subclassing you only need to change
this method.
For more information refer to :ref:`url-route-registrations`.
.. versionchanged:: 0.2
`view_func` parameter added.
.. versionchanged:: 0.6
``OPTIONS`` is added automatically as method.
:param rule: the URL rule as string
:param endpoint: the endpoint for the registered URL rule. Flask
itself assumes the name of the view function as
endpoint
:param view_func: the function to call when serving a request to the
provided endpoint
:param provide_automatic_options: controls whether the ``OPTIONS``
method should be added automatically. This can also be controlled
by setting the ``view_func.provide_automatic_options = False``
before adding the rule.
:param options: the options to be forwarded to the underlying
:class:`~werkzeug.routing.Rule` object. A change
to Werkzeug is handling of method options. methods
is a list of methods this rule should be limited
to (``GET``, ``POST`` etc.). By default a rule
just listens for ``GET`` (and implicitly ``HEAD``).
Starting with Flask 0.6, ``OPTIONS`` is implicitly
added and handled by the standard request handling.
Nre<00>methods)<01>GETz_Allowed methods have to be iterables of strings, for example: @app.route(..., methods=["POST"])css|]}|<01><00>VqdS)N)<01>upper)r<><00>itemr=r=r>r<><00>sz%Flask.add_url_rule.<locals>.<genexpr><3E>required_methodsr=<00>provide_automatic_options<6E>OPTIONSTFzFView function mapping is overwriting an existing endpoint function: %s)r$<00>popr<70>r;r<00> TypeError<6F>set<65>add<64>url_rule_classr<73>r<>rsr<>rB) rC<00>rulerergr<>r<>r<>r<>Zold_funcr=r=r>r<><00>s<= 

  
 zFlask.add_url_rulec s<00><00><01>fdd<02>}|S)a<>A decorator that is used to register a view function for a
given URL rule. This does the same thing as :meth:`add_url_rule`
but is intended for decorator usage::
@app.route('/')
def index():
return 'Hello World'
For more information refer to :ref:`url-route-registrations`.
:param rule: the URL rule as string
:param endpoint: the endpoint for the registered URL rule. Flask
itself assumes the name of the view function as
endpoint
:param options: the options to be forwarded to the underlying
:class:`~werkzeug.routing.Rule` object. A change
to Werkzeug is handling of method options. methods
is a list of methods this rule should be limited
to (``GET``, ``POST`` etc.). By default a rule
just listens for ``GET`` (and implicitly ``HEAD``).
Starting with Flask 0.6, ``OPTIONS`` is implicitly
added and handled by the standard request handling.
cs"<00><00>dd<00>}<01>j<01>||f<03><00>|S)Nre)r<>r<>)rFre)r<>r<>rCr=r><00> decorator s zFlask.route.<locals>.decoratorr=)rCr<>r<>r<>r=)r<>r<>rCr><00>routesz Flask.routecs<00><00>fdd<02>}|S)z<>A decorator to register a function as an endpoint.
Example::
@app.endpoint('example.endpoint')
def example():
return "example"
:param endpoint: the name of the endpoint
cs|<00>j<00><|S)N)rs)rF)rerCr=r>r<>3s
z!Flask.endpoint.<locals>.decoratorr=)rCrer<>r=)rerCr>re's zFlask.endpointcCsFt|t<01>rt|}n|}t|t<04>s&t<05>t|t<06>r:||jfS|dfSdS)a Get the exception class being handled. For HTTP status codes
or ``HTTPException`` subclasses, return both the exception and
status code.
:param exc_class_or_code: Any exception class, or an HTTP status
code as an integer.
N)r;rr
<00>
issubclass<EFBFBD> ExceptionrBr <00>code)Zexc_class_or_code<64> exc_classr=r=r><00>_get_exc_class_and_code9s



zFlask._get_exc_class_and_codecs<00><00>fdd<02>}|S)a7Register a function to handle errors by code or exception class.
A decorator that is used to register a function given an
error code. Example::
@app.errorhandler(404)
def page_not_found(error):
return 'This page does not exist', 404
You can also register handlers for arbitrary exceptions::
@app.errorhandler(DatabaseError)
def special_exception_handler(error):
return 'Database connection failed', 500
.. versionadded:: 0.7
Use :meth:`register_error_handler` instead of modifying
:attr:`error_handler_spec` directly, for application wide error
handlers.
.. versionadded:: 0.7
One can now additionally also register custom exception types
that do not necessarily have to be a subclass of the
:class:`~werkzeug.exceptions.HTTPException` class.
:param code_or_exception: the code as integer for the handler, or
an arbitrary exception
cs<00><01>d<00>|<00>|S)N)<01>_register_error_handler)rF)<02>code_or_exceptionrCr=r>r<>msz%Flask.errorhandler.<locals>.decoratorr=)rCr<>r<>r=)r<>rCr><00> errorhandlerNszFlask.errorhandlercCs|<00>d||<02>dS)z<>Alternative error attach function to the :meth:`errorhandler`
decorator that is more straightforward to use for non decorator
usage.
.. versionadded:: 0.7
N)r<>)rCr<>rFr=r=r><00>register_error_handlersszFlask.register_error_handlercCspt|t<01>rtd<01>|<02><01><01>y|<00>|<02>\}}Wn"tk
rLtd<02>|<02><01><01>YnX|j<06>|i<00><02>|i<00>}|||<dS)zq
:type key: None|str
:type code_or_exception: int|T<=Exception
:type f: callable
z<>Tried to register a handler for an exception instance {0!r}. Handlers can only be registered for exception classes or HTTP error codes.zb'{0}' is not a recognized HTTP error code. Use a subclass of HTTPException with that code instead.N)r;r ro<00>formatr<74><00>KeyErrorrtr<>)rC<00>keyr<79>rFr<>r<><00>handlersr=r=r>r<>}s
zFlask._register_error_handlercs<00><00>fdd<02>}|S)aA decorator that is used to register custom template filter.
You can specify a name for the filter, otherwise the function
name will be used. Example::
@app.template_filter()
def reverse(s):
return s[::-1]
:param name: the optional name of the filter, otherwise the
function name will be used.
cs<00>j|<00>d<01>|S)N)r<>)<01>add_template_filter)rF)r<>rCr=r>r<><00>sz(Flask.template_filter.<locals>.decoratorr=)rCr<>r<>r=)r<>rCr><00>template_filter<65>szFlask.template_filtercCs||jj|p|j<dS)z<>Register 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<>r<><00>__name__)rCrFr<>r=r=r>r<00>szFlask.add_template_filtercs<00><00>fdd<02>}|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.
cs<00>j|<00>d<01>|S)N)r<>)<01>add_template_test)rF)r<>rCr=r>r<><00>sz&Flask.template_test.<locals>.decoratorr=)rCr<>r<>r=)r<>rCr><00> template_test<73>szFlask.template_testcCs||jj|p|j<dS)z<>Register 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<><00>testsr)rCrFr<>r=r=r>r<00>s
zFlask.add_template_testcs<00><00>fdd<02>}|S)a<>A 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.
cs<00>j|<00>d<01>|S)N)r<>)<01>add_template_global)rF)r<>rCr=r>r<><00>sz(Flask.template_global.<locals>.decoratorr=)rCr<>r<>r=)r<>rCr><00>template_global<61>szFlask.template_globalcCs||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<>r<>r)rCrFr<>r=r=r>r <00>s
zFlask.add_template_globalcCs|j<00>dg<00><02>|<01>|S)a<>Registers 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.
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.
N)rvr<>r<>)rCrFr=r=r><00>before_request<73>s zFlask.before_requestcCs|j<00>|<01>|S)z<>Registers a function to be run before the first request to this
instance of the application.
The function will be called without any arguments and its return
value is ignored.
.. versionadded:: 0.8
)rwr<>)rCrFr=r=r><00>before_first_request s
zFlask.before_first_requestcCs|j<00>dg<00><02>|<01>|S)auRegister a function to be run after each request.
Your function must take one parameter, an instance of
:attr:`response_class` and return a new response object or the
same (see :meth:`process_response`).
As of Flask 0.7 this function might not be executed at the end of the
request in case an unhandled exception occurred.
N)rxr<>r<>)rCrFr=r=r><00> after_requests zFlask.after_requestcCs|j<00>dg<00><02>|<01>|S)a<>Register a function to be run at the end of each request,
regardless of whether there was an exception or not. These functions
are executed when the request context is popped, even if not an
actual request was performed.
Example::
ctx = app.test_request_context()
ctx.push()
...
ctx.pop()
When ``ctx.pop()`` is executed in the above example, the teardown
functions are called just before the request context moves from the
stack of active contexts. This becomes relevant if you are using
such constructs in tests.
Generally teardown functions must take every necessary step to avoid
that they will fail. If they do execute code that might fail they
will have to surround the execution of these code by try/except
statements and log occurring errors.
When a teardown function was called because of an exception it will
be passed an error object.
The return values of teardown functions are ignored.
.. admonition:: Debug Note
In debug mode Flask will not tear down a request on an exception
immediately. Instead it will keep it alive so that the interactive
debugger can still access it. This behavior can be controlled
by the ``PRESERVE_CONTEXT_ON_EXCEPTION`` configuration variable.
N)ryr<>r<>)rCrFr=r=r><00>teardown_request&s$zFlask.teardown_requestcCs|j<00>|<01>|S)aRegisters a function to be called when the application context
ends. These functions are typically also called when the request
context is popped.
Example::
ctx = app.app_context()
ctx.push()
...
ctx.pop()
When ``ctx.pop()`` is executed in the above example, the teardown
functions are called just before the app context moves from the
stack of active contexts. This becomes relevant if you are using
such constructs in tests.
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.
The return values of teardown functions are ignored.
.. versionadded:: 0.9
)rzr<>)rCrFr=r=r><00>teardown_appcontextMs zFlask.teardown_appcontextcCs|jd<00>|<01>|S)z0Registers a template context processor function.N)r}r<>)rCrFr=r=r><00>context_processornszFlask.context_processorcCs|j<00>|<01>|S)zVRegisters a shell context processor function.
.. versionadded:: 0.11
)r~r<>)rCrFr=r=r><00>shell_context_processorts zFlask.shell_context_processorcCs|j<00>dg<00><02>|<01>|S)a#Register a URL value preprocessor function for all view
functions in the application. These functions will be called before the
:meth:`before_request` functions.
The function can modify the values captured from the matched url before
they are passed to the view. For example, this can be used to pop a
common language code value and place it in ``g`` rather than pass it to
every view.
The function is passed the endpoint name and values dict. The return
value is ignored.
N)r{r<>r<>)rCrFr=r=r><00>url_value_preprocessor}szFlask.url_value_preprocessorcCs|j<00>dg<00><02>|<01>|S)z<>Callback function for URL defaults for all view functions of the
application. It's called with the endpoint and values and should
update the values passed in place.
N)r|r<>r<>)rCrFr=r=r><00> url_defaults<74>szFlask.url_defaultsc Cs<>|<00>t|<01><01>\}}xhtj|fd|ftjdfdfD]H\}}|j<04>|i<00><02>|<05>}|sRq0x$|jD]}|<06>|<07>}|dk rZ|SqZWq0WdS)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.
N)NN)r<><00>typer"r<>rtr<>r<><00>__mro__) rC<00>er<65>r<>r<><00>cZ handler_mapr<70><00>handlerr=r=r><00>_find_error_handler<65>s 
zFlask._find_error_handlercCs:|jdkr|St|t<02>r|S|<00>|<01>}|dkr2|S||<01>S)acHandles an HTTP exception. By default this will invoke the
registered error handlers and fall back to returning the
exception as response.
.. versionchanged:: 1.0.3
``RoutingException``, used internally for actions such as
slash redirects during routing, is not passed to error
handlers.
.. versionchanged:: 1.0
Exceptions are looked up by code *and* by MRO, so
``HTTPExcpetion`` subclasses can be handled with a catch-all
handler for the base ``HTTPException``.
.. versionadded:: 0.3
N)r<>r;rr)rCrrr=r=r><00>handle_http_exception<6F>s


zFlask.handle_http_exceptioncCsF|jdrdS|jd}|dkr4|jr4t|t<03>r4dS|rBt|t<04>SdS)a<>Checks 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
r^Tr]NF)rrr@r;r r)rCrZtrap_bad_requestr=r=r><00>trap_http_exception<6F>s



zFlask.trap_http_exceptioncCs<>t<00><01>\}}}||kst<02>t|t<04>rl|js4|jdr\d|_|jd|<01> <09>krldj
|j<08>|_ nt td<05>sld|_t|t <0A>r<>|<00>|<01>s<>|<00>|<01>S|<00>|<01>}|dkr<>t|||<04>||<01>S)a>This method is called whenever an exception occurs that
should be handled. A special case is :class:`~werkzeug
.exceptions.HTTPException` which is forwarded to the
:meth:`handle_http_exception` method. This function will either
return a response value or reraise the exception with the same
traceback.
.. versionchanged:: 1.0
Key errors raised from request data like ``form`` show the
bad key in debug mode rather than a generic bad request
message.
.. versionadded:: 0.7
r]TrzKeyError: '{}'<27>show_exceptionr=N)r<><00>exc_inforBr;r r@rrrrD<00>get_descriptionr<6E><00> description<6F>hasattrr rrrr)rCr<00>exc_type<70> exc_value<75>tbrr=r=r><00>handle_user_exception<6F>s 



 zFlask.handle_user_exceptioncCs<>t<00><01>\}}}tj||d<01>|jr<||kr8t|||<04>n|<01>|<00>|||f<03>t<07>}||_|<00> |<05>}|dk rr||<05>}|j
|dd<04>S)a<>Handle an exception that did not have an error handler
associated with it, or that was raised from an error handler.
This always causes a 500 ``InternalServerError``.
Always sends the :data:`got_request_exception` signal.
If :attr:`propagate_exceptions` is ``True``, such as in debug
mode, the error will be re-raised so that the debugger can
display it. Otherwise, the original exception is logged, and
an :exc:`~werkzeug.exceptions.InternalServerError` is returned.
If an error handler is registered for ``InternalServerError`` or
``500``, it will be used. For consistency, the handler will
always receive the ``InternalServerError``. The original
unhandled exception is available as ``e.original_exception``.
.. note::
Prior to Werkzeug 1.0.0, ``InternalServerError`` will not
always have an ``original_exception`` attribute. Use
``getattr(e, "original_exception", None)`` to simulate the
behavior for compatibility.
.. versionchanged:: 1.1.0
Always passes the ``InternalServerError`` instance to the
handler, setting ``original_exception`` to the unhandled
error.
.. versionchanged:: 1.1.0
``after_request`` functions and other finalization is done
even for the default 500 response when there is no handler.
.. versionadded:: 0.3
)<01> exceptionNT)<01>from_error_handler) r<>rr1<00>sendr<64>r<00> log_exceptionr Zoriginal_exceptionr<00>finalize_request)rCrr!r"r#<00> server_errorrr=r=r><00>handle_exceptions"
zFlask.handle_exceptioncCs |jjdtjtjf|d<02>dS)a Logs an exception. This is called by :meth:`handle_exception`
if debugging is disabled and right before the handler is called.
The default implementation logs the exception as error on the
:attr:`logger`.
.. versionadded:: 0.8
zException on %s [%s])rN)r<><00>errorr"rm<00>method)rCrr=r=r>r(ZszFlask.log_exceptioncCs:|jrt|jt<03>r|jdkr"|j<02>ddlm}||<01><01>dS)a.Exceptions that are recording during routing are reraised with
this method. During debug we are not reraising redirect requests
for non ``GET``, ``HEAD``, or ``OPTIONS`` requests and we're raising
a different error instead to help debug situations.
:internal:
)r<><00>HEADr<44>r)<01>FormDataRoutingRedirectN)r@r;<00>routing_exceptionrr-r<>r/)rCr"r/r=r=r><00>raise_routing_exceptionfs  
 zFlask.raise_routing_exceptioncCsTtjj}|jdk r|<00>|<01>|j}t|dd<03>r@|jdkr@|<00><08>S|j |j
f|j <0B>S)a<>Does the request dispatching. Matches the URL and returns the
return value of the view or error handler. This does not have to
be a response object. In order to convert the return value to a
proper response object, call :func:`make_response`.
.. versionchanged:: 0.7
This no longer does the exception handling, this code was
moved to the new :meth:`full_dispatch_request`.
Nr<4E>Fr<46>) r r<>r"r0r1Zurl_ruler<65>r-<00>make_default_options_responsersre<00> view_args)rC<00>reqr<71>r=r=r><00>dispatch_requestys


 
zFlask.dispatch_requestc
Csf|<00><00>y&t<01>|<00>|<00><03>}|dkr,|<00><04>}Wn,tk
rZ}z|<00>|<02>}Wdd}~XYnX|<00>|<01>S)z<>Dispatches the request and on top of that performs request
pre and postprocessing as well as HTTP exception catching and
error handling.
.. versionadded:: 0.7
N)<08>*try_trigger_before_first_request_functionsr3r'<00>preprocess_requestr5r<>r$r))rCr<>rr=r=r><00>full_dispatch_request<73>s
 zFlask.full_dispatch_requestcCsR|<00>|<01>}y|<00>|<03>}tj||d<01>Wn&tk
rL|s<<3C>|j<05>d<02>YnX|S)a)Given the return value from a view function this finalizes
the request by converting it into a response and invoking the
postprocessing functions. This is invoked for both normal
request dispatching as well as error handlers.
Because this means that it might be called as a result of a
failure a special safe mode is available which can be enabled
with the `from_error_handler` flag. If enabled, failures in
response processing will be logged and otherwise ignored.
:internal:
)r<>z?Request finalizing failed with an error while handling an error)<07> make_response<73>process_responser2r'r<>r<>r%)rCr<>r&r<>r=r=r>r)<00>s

 zFlask.finalize_requestc CsF|jr
dS|j<01>,|jrdSx|jD]
}|<01>q$Wd|_WdQRXdS)z<>Called before each request and will ensure that it triggers
the :attr:`before_first_request_funcs` and only exactly once per
application instance (which means process usually).
:internal:
NT)rAr<>rw)rCr<>r=r=r>r6<00>s 
z0Flask.try_trigger_before_first_request_functionsc
Cs<>tjj}t|d<01>r|<01><04>}nPg}y|jdd<03>Wn:tk
rX}z
|j}Wdd}~XYntk
rjYnX|<00> <09>}|j
<EFBFBD> |<02>|S)z<>This method is called to create the default ``OPTIONS`` response.
This can be changed through subclassing to change the default
behavior of ``OPTIONS`` responses.
.. versionadded:: 0.7
<20>allowed_methodsz--)r-N) r r<>Z url_adapterr r;<00>matchr Z valid_methodsr r<>Zallowr<77>)rC<00>adapterr<72>rr<>r=r=r>r2<00>s

 z#Flask.make_default_options_responsecCsdS)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=)rCr,r=r=r><00>should_ignore_error<6F>szFlask.should_ignore_errorc
Cs<>d}}t|t<01>rht|<01>}|dkr.|\}}}n:|dkr`t|dttttf<04>rV|\}}qh|\}}ntd<05><01>|dkrxtd<06><01>t||j<07><02>sJt|tt t
f<03>r<>|j|||d<07>}d}}n<>t|t<04>r<>t |<01>}n<>t|t <0C>s<>t |<01><01>r:y|j<07>|tj<10>}WnJtk
<EFBFBD>r6}z*tdj||d <09><02>}tt|t<13><14>d<00>Wdd}~XYnXntd
j|d <0B><01><01>|dk <09>rtt|tt t
f<03><02>rn||_n||_|<03>r<>|j<17>|<03>|S) a<>Convert the return value from a view function to an instance of
:attr:`response_class`.
:param rv: the return value from the view function. The view function
must return a response. Returning ``None``, or the view ending
without returning, is not allowed. The following types are allowed
for ``view_rv``:
``str`` (``unicode`` in Python 2)
A response object is created with the string encoded to UTF-8
as the body.
``bytes`` (``str`` in Python 2)
A response object is created with the bytes as the body.
``dict``
A dictionary that will be jsonify'd before being returned.
``tuple``
Either ``(body, status, headers)``, ``(body, status)``, or
``(body, headers)``, where ``body`` is any of the other types
allowed here, ``status`` is a string or an integer, and
``headers`` is a dictionary or a list of ``(key, value)``
tuples. If ``body`` is a :attr:`response_class` instance,
``status`` overwrites the exiting value and ``headers`` are
extended.
:attr:`response_class`
The object is returned unchanged.
other :class:`~werkzeug.wrappers.Response` class
The object is coerced to :attr:`response_class`.
:func:`callable`
The function is called as a WSGI application. The result is
used to create a response object.
.. versionchanged:: 0.9
Previously a tuple was interpreted as the arguments for the
response object.
N<><00>rz<>The view function did not return a valid response tuple. The tuple must have the form (body, status, headers), (body, status), or (body, headers).zyThe view function did not return a valid response. The function either returned None or ended without a return statement.)<02>status<75>headersz<73>{e}
The view function did not return a valid response. The return type must be a string, dict, tuple, Response instance, or WSGI callable, but it was a {rv.__class__.__name__}.)rr<>z<>The view function did not return a valid response. The return type must be a string, dict, tuple, Response instance, or WSGI callable, but it was a {rv.__class__.__name__}.)r<>)r;<00>tuple<6C>lenrr<><00>listr<74>r<>r<00>bytes<65> bytearrayr-r<00>callableZ
force_typer"r<>r<>rr<>rrA<00> status_coderB<00>extend)rCr<>rArBZlen_rvrZ new_errorr=r=r>r9<00>sL+
 




 (

 zFlask.make_responsecCsn|dk r8|js|jjpdnd}|jj|j|jd|d<03>S|jddk rj|jj|jd|jd|jdd<06>SdS)a*Creates a URL adapter for the given request. The URL adapter
is created at a point where the request context is not yet set
up so the request is passed explicitly.
.. versionadded:: 0.6
.. versionchanged:: 0.9
This can now also be called without a request object when the
URL adapter is created for the application context.
.. versionchanged:: 1.0
:data:`SERVER_NAME` no longer implicitly enables subdomain
matching. Use :attr:`subdomain_matching` instead.
Nr[)r<><00> subdomainr\r_)<02> script_nameZ
url_scheme)r<>r<>Zdefault_subdomainZbind_to_environr<6E>rr<00>bind)rCr"rKr=r=r><00>create_url_adapterbszFlask.create_url_adaptercCsV|j<00>dd<02>}d|kr:|<01>dd<04>d}t||j<00>|d<02><02>}x|D]}|||<02>q@WdS)z<>Injects 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
Nr=<00>.rr)r|r<><00>rsplitr)rCre<00>valuesr<73>r<>r<>r=r=r><00>inject_url_defaults<74>s 
zFlask.inject_url_defaultsc
Cs~t<00><01>\}}}xR|jD]H}y||||<03>}|dk r4|SWqtk
r\} z| }Wdd} ~ XYqXqW||krvt|||<06>|<01>dS)zIHandle :class:`~werkzeug.routing.BuildError` on :meth:`url_for`.
N)r<>rrurr)
rCr,rerQr!r"r#rr<>rr=r=r><00>handle_url_build_error<6F>s   zFlask.handle_url_build_errorcCs<>tjjj}|j<04>dd<02>}|dk r:||jkr:t||j|<00>}x|D]}|tjtj<08>q@W|j <09>dd<02>}|dk r<>||j kr<>t||j |<00>}x|D]}|<03>}|dk r<>|Sq<>WdS)a<>Called before the request is dispatched. Calls
:attr:`url_value_preprocessors` registered with the app and the
current blueprint (if any). Then calls :attr:`before_request_funcs`
registered with the app and the blueprint.
If any :meth:`before_request` handler 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.
Nr=)
r r<>r"r<>r{r<>rrer3rv)rCr<>r<>r<>r<>r=r=r>r7<00>s


zFlask.preprocess_requestcCs<>tj}|jj}|j}|dk r:||jkr:t|t|j|<00><01>}d|jkrXt|t|jd<00><01>}x|D] }||<01>}q^W|j<08> |j
<EFBFBD>s<>|j<08> ||j
|<01>|S)aCan be overridden in order to modify the response object
before it's sent to the WSGI server. By default this will
call all the :meth:`after_request` decorated functions.
.. versionchanged:: 0.5
As of Flask 0.5 the functions registered for after request
execution are called in reverse order of registration.
:param response: a :attr:`response_class` object.
:return: a new response object or the same, has to be an
instance of :attr:`response_class`.
N) r r<>r"r<>Z_after_request_functionsrxr<00>reversedr<64>Zis_null_sessionr#r<>)rCr<><00>ctxr<78>r<>rr=r=r>r:<00>s 

 zFlask.process_responsecCs~|tkrt<01><02>d}t|j<04>dd<03><02>}tjjj }|dk rV||jkrVt
|t|j|<00><01>}x|D] }||<01>q\Wt j ||d<04>dS)a2Called after the request is dispatched and the response is
returned, right before the request context is popped.
This calls all functions decorated with
:meth:`teardown_request`, and :meth:`Blueprint.teardown_request`
if a blueprint handled the request. Finally, the
:data:`request_tearing_down` signal is sent.
This is called by
:meth:`RequestContext.pop() <flask.ctx.RequestContext.pop>`,
which may be delayed during testing to maintain access to
resources.
:param exc: An unhandled exception raised while dispatching the
request. Detected from the current exception information if
not passed. Passed to each teardown function.
.. versionchanged:: 0.9
Added the ``exc`` argument.
rNr=)<01>exc) <0A> _sentinelr<6C>rrTryr<>r r<>r"r<>rr4r')rCrVr<>r<>r<>r=r=r><00>do_teardown_request<73>s 

 zFlask.do_teardown_requestcCsB|tkrt<01><02>d}xt|j<04>D] }||<01>q Wtj||d<02>dS)a<>Called right before the application context is popped.
When handling a request, the application context is popped
after the request context. See :meth:`do_teardown_request`.
This calls all functions decorated with
:meth:`teardown_appcontext`. Then the
:data:`appcontext_tearing_down` signal is sent.
This is called by
:meth:`AppContext.pop() <flask.ctx.AppContext.pop>`.
.. versionadded:: 0.9
r)rVN)rWr<>rrTrzr0r')rCrVr<>r=r=r><00>do_teardown_appcontext<78>s
  zFlask.do_teardown_appcontextcCst|<00>S)aFCreate an :class:`~flask.ctx.AppContext`. Use as a ``with``
block to push the context, which will make :data:`current_app`
point at this application.
An application context is automatically pushed by
:meth:`RequestContext.push() <flask.ctx.RequestContext.push>`
when handling a request, and when running a CLI command. Use
this to manually create a context outside of these situations.
::
with app.app_context():
init_db()
See :doc:`/appcontext`.
.. versionadded:: 0.9
)r)rCr=r=r><00> app_context szFlask.app_contextcCs
t||<01>S)a$Create a :class:`~flask.ctx.RequestContext` representing a
WSGI environment. Use a ``with`` block to push the context,
which will make :data:`request` point at this request.
See :doc:`/reqcontext`.
Typically you should not call this from your own code. A request
context is automatically pushed by the :meth:`wsgi_app` when
handling a request. Use :meth:`test_request_context` to create
an environment and context instead of this method.
:param environ: a WSGI environment
)r)rCr<>r=r=r><00>request_context( szFlask.request_contextcOs:ddlm}||f|<01>|<02>}z|<00>|<04><03><00>S|<04><04>XdS)a<>Create a :class:`~flask.ctx.RequestContext` for a WSGI
environment created from the given values. This is mostly useful
during testing, where you may want to run a function that uses
request data without dispatching a full request.
See :doc:`/reqcontext`.
Use a ``with`` block to push the context, which will make
:data:`request` point at the request for the created
environment. ::
with test_request_context(...):
generate_report()
When using the shell, it may be easier to push and pop the
context manually to avoid indentation. ::
ctx = app.test_request_context(...)
ctx.push()
...
ctx.pop()
Takes the same arguments as Werkzeug's
:class:`~werkzeug.test.EnvironBuilder`, with some defaults from
the application. See the linked Werkzeug docs for most of the
available arguments. Flask-specific behavior is listed here.
:param path: URL path being requested.
:param base_url: Base URL where the app is being served, which
``path`` is relative to. If not given, built from
:data:`PREFERRED_URL_SCHEME`, ``subdomain``,
:data:`SERVER_NAME`, and :data:`APPLICATION_ROOT`.
:param subdomain: Subdomain name to append to
:data:`SERVER_NAME`.
:param url_scheme: Scheme to use instead of
:data:`PREFERRED_URL_SCHEME`.
:param data: The request body, either as a string or a dict of
form keys and values.
:param json: If given, this is serialized as JSON and passed as
``data``. Also defaults ``content_type`` to
``application/json``.
:param args: other positional arguments passed to
:class:`~werkzeug.test.EnvironBuilder`.
:param kwargs: other keyword arguments passed to
:class:`~werkzeug.test.EnvironBuilder`.
r)<01>EnvironBuilderN)r<>r\r[Z get_environ<6F>close)rCrDrEr\<00>builderr=r=r><00>test_request_context8 s
/ zFlask.test_request_contextc
Cs<>|<00>|<01>}d}zhy|<03><01>|<00><02>}WnHtk
rT}z|}|<00>|<06>}Wdd}~XYnt<05><06>d}<04>YnX|||<02>S|<00>|<04>r<>d}|<03>|<04>XdS)a<>The actual WSGI application. This is not implemented in
:meth:`__call__` so that middlewares can be applied without
losing a reference to the app object. Instead of doing this::
app = MyMiddleware(app)
It's a better idea to do this instead::
app.wsgi_app = MyMiddleware(app.wsgi_app)
Then you still have the original application object around and
can continue to call methods on it.
.. versionchanged:: 0.7
Teardown events for the request and app contexts are called
even if an unhandled error occurs. Other events may not be
called depending on when an error occurs during dispatch.
See :ref:`callbacks-and-errors`.
:param environ: A WSGI environment.
:param start_response: A callable accepting a status code,
a list of headers, and an optional exception context to
start the response.
Nr) r[<00>pushr8r<>r+r<>rr>Zauto_pop)rCr<><00>start_responserUr,r<>rr=r=r><00>wsgi_appp s 
  

zFlask.wsgi_appcCs |<00>||<02>S)z<>The WSGI server calls the Flask application object as the
WSGI application. This calls :meth:`wsgi_app` which can be
wrapped to applying middleware.)rb)rCr<>rar=r=r><00>__call__<5F> szFlask.__call__cCsd|jj|jfS)Nz<%s %r>)<03> __class__rr<>)rCr=r=r><00>__repr__<5F> szFlask.__repr__) NraNFFrbNFN)F)r<>)NNNT)T)NNN)N)N)N)N)N)N)F){r<00>
__module__<EFBFBD> __qualname__<5F>__doc__r8Z request_classr9r<>r7r<>rZapp_ctx_globals_classrr<>rr<>Z
secret_keyZsession_cookie_namer?Zpermanent_session_lifetimeZsend_file_max_age_defaultZuse_x_sendfiler<00> JSONEncoderZ json_encoder<65> JSONDecoderZ json_decoderr<72>rrr<>rr<>rr<>r<>r<>r/r<>r<>rcrdrhr+r<><00>propertyr<79>r<>r<>r<>r<>rqrkr<>r<><00>setterr<72>r<>r<>r<>r<>r<>r@r<>r<>r<>r<>r<>r<>rHr<>r<>r<>r<>re<00> staticmethodr<64>r<>r<>r<>rrrrr
r r r r rrrrrrrrrr$r+r(r1r5r8r)r6r2r>r9rNrRrSr7r:rWrXrYrZr[r_rbrcrer=r=r=r>rIgs,a   

 

H  

# 
 
l
8 $ i   %
        ' !   !#+; 

v&  8+rI)Srhrlr<>r<><00>datetimer<00> functoolsr<00> itertoolsr<00> threadingrZwerkzeug.datastructuresrrZwerkzeug.exceptionsrr r
r r r Zwerkzeug.routingrrrrrZwerkzeug.wrappersr<00>rr<00>_compatrrrrrrrrrUrrrr<>r r!r"r#Zhelpersr$r%r&r'r(r)r*r+r,r-<00>loggingr.<00>sessionsr/Zsignalsr0r1r2r3r4Z
templatingr5r6r7<00>wrappersr8r9<00>objectrWr?rHrIr=r=r=r><00><module>
s|