zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
U
ß=®d}aã @sRddlmZddlZddlZddlZddlZddlZddlZddl    m    Z    ddl
m Z ddl
m Z ddl mZddlZddlmZddlmZd    d
lmZd    d lmZd    d lmZd    d lmZd    dlmZd    dlmZejròddlm Z!d    dl"m Z ddœdd„Z#dadddœdd„Z$dddœdd„Z%ddd œd!d"„Z&ddddd#œd$d%d%d%d&dd$d'œd(d)„Z'dbd$d+d,d-d.œd/d0„Zd1ddd2d3œd4d5„Zd$d$dd6œd7d8„Z(dcd$d$d:d;œd<d=„Z)dddd@dAdBœdCdD„Z*ddEdFœdGdH„Z+dedId%dd%ddJdKdLddMœ    dNdO„Z,dPdPdddQœdRdS„Z-d$d$dTœdUdV„Z.GdWdX„dXej/j0ƒZ1d$ddYœdZd[„Z2e dd\d$d]d^œd_d`„ƒZ3dS)fé)Ú annotationsN)Údatetime)Ú    lru_cache)Úupdate_wrapper)ÚRLock)Úabort)Úredirecté)Ú _cv_request)Ú current_app)Úrequest)Ú request_ctx)Úsession)Úmessage_flashed)ÚResponseÚbool©ÚreturncCs tj d¡}t|o| ¡dkƒS)z•Get whether debug mode should be enabled for the app, indicated by the
    :envvar:`FLASK_DEBUG` environment variable. The default is ``False``.
    Z FLASK_DEBUG>Ú0ÚnoÚfalse)ÚosÚenvironÚgetrÚlower)Úval©rúDd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\flask/helpers.pyÚget_debug_flags rT)ÚdefaultrcCs tj d¡}|s|S| ¡dkS)zÚGet whether the user has disabled loading default dotenv files by
    setting :envvar:`FLASK_SKIP_DOTENV`. The default is ``True``, load
    the files.
 
    :param default: What to return if the env var isn't set.
    ZFLASK_SKIP_DOTENV)rrr)rrrr)rrrrrÚget_load_dotenv&s r z<t.Iterator[t.AnyStr] | t.Callable[..., t.Iterator[t.AnyStr]]zt.Iterator[t.AnyStr])Úgenerator_or_functionrcsfz tˆƒ‰Wn4tk
r@ddddœ‡fdd„ }t|ˆƒYSXddœ‡fdd„ }|ƒ}t|ƒ|S)    a‹Request contexts disappear when the response is started on the server.
    This is done for efficiency reasons and to make it less likely to encounter
    memory leaks with badly written WSGI middlewares.  The downside is that if
    you are using streamed responses, the generator cannot access request bound
    information any more.
 
    This function however can help you keep the context around for longer::
 
        from flask import stream_with_context, request, Response
 
        @app.route('/stream')
        def streamed_response():
            @stream_with_context
            def generate():
                yield 'Hello '
                yield request.args['name']
                yield '!'
            return Response(generate())
 
    Alternatively it can also be used around a specific generator::
 
        from flask import stream_with_context, request, Response
 
        @app.route('/stream')
        def streamed_response():
            def generate():
                yield 'Hello '
                yield request.args['name']
                yield '!'
            return Response(stream_with_context(generate()))
 
    .. versionadded:: 0.9
    út.Any)ÚargsÚkwargsrcsˆ||Ž}t|ƒS©N)Ústream_with_context)r#r$Úgen)r!rrÚ    decorator_s
z&stream_with_context.<locals>.decoratorz t.Generatorrc
3sXt d¡}|dkrtdƒ‚|0dVzˆEdHW5tˆdƒrHˆ ¡XW5QRXdS)Nzd'stream_with_context' can only be used when a request context is active, such as in a view function.Úclose)r
rÚ RuntimeErrorÚhasattrr))Úctx)r'rrÚ    generatores
ÿ
z&stream_with_context.<locals>.generator)ÚiterÚ    TypeErrorrÚnext)r!r(r-Z    wrapped_gr)r'r!rr&5s& r&r"r)r#rcGs*|s t ¡St|ƒdkr |d}t |¡S)aySometimes it is necessary to set additional headers in a view.  Because
    views do not have to return response objects but can return a value that
    is converted into a response object by Flask itself, it becomes tricky to
    add headers to it.  This function can be called instead of using a return
    and you will get a response object which you can use to attach headers.
 
    If view looked like this and you want to add a new header::
 
        def index():
            return render_template('index.html', foo=42)
 
    You can now do something like this::
 
        def index():
            response = make_response(render_template('index.html', foo=42))
            response.headers['X-Parachutes'] = 'parachutes are cool'
            return response
 
    This function accepts the very same arguments you can return from a
    view function.  This for example creates a response with a 404 error
    code::
 
        response = make_response(render_template('not_found.html'), 404)
 
    The other use case of this function is to force the return value of a
    view function into a response which is helpful with view
    decorators::
 
        response = make_response(view_function())
        response.headers['X-Parachutes'] = 'parachutes are cool'
 
    Internally this function does the following things:
 
    -   if no arguments are passed, it creates a new response argument
    -   if one argument is passed, :meth:`flask.Flask.make_response`
        is invoked with it.
    -   if more than one argument is passed, the arguments are passed
        to the :meth:`flask.Flask.make_response` function as tuple.
 
    .. versionadded:: 0.6
    r    r)r Úresponse_classÚlenÚ make_response)r#rrrr3„s
* r3©Ú_anchorÚ_methodÚ_schemeÚ    _externalÚstrú
str | Nonez bool | None)Úendpointr5r6r7r8ÚvaluesrcKstj|f||||dœ|—ŽS)aœGenerate a URL to the given endpoint with the given values.
 
    This requires an active request or application context, and calls
    :meth:`current_app.url_for() <flask.Flask.url_for>`. See that method
    for full documentation.
 
    :param endpoint: The endpoint name associated with the URL to
        generate. If this starts with a ``.``, the current blueprint
        name (if any) will be used.
    :param _anchor: If given, append this as ``#anchor`` to the URL.
    :param _method: If given, generate the URL associated with this
        method for the endpoint.
    :param _scheme: If given, the URL will have this scheme if it is
        external.
    :param _external: If given, prefer the URL to be internal (False) or
        require it to be external (True). External URLs include the
        scheme and domain. When not in an active request, URLs are
        external by default.
    :param values: Values to use for the variable parts of the URL rule.
        Unknown keys are appended as query string arguments, like
        ``?a=b&c=d``.
 
    .. versionchanged:: 2.2
        Calls ``current_app.url_for``, allowing an app to override the
        behavior.
 
    .. versionchanged:: 0.10
       The ``_scheme`` parameter was added.
 
    .. versionchanged:: 0.9
       The ``_anchor`` and ``_method`` parameters were added.
 
    .. versionchanged:: 0.9
       Calls ``app.handle_url_build_error`` on build errors.
    r4)r Úurl_for)r;r5r6r7r8r<rrrr=µs,ÿûúr=é.Úintztype[BaseResponse] | NoneÚ BaseResponse)ÚlocationÚcoderrcCs trtj||dSt|||dS)aBCreate a redirect response object.
 
    If :data:`~flask.current_app` is available, it will use its
    :meth:`~flask.Flask.redirect` method, otherwise it will use
    :func:`werkzeug.utils.redirect`.
 
    :param location: The URL to redirect to.
    :param code: The status code for the redirect.
    :param Response: The response class to use. Not used when
        ``current_app`` is active, which uses ``app.response_class``.
 
    .. versionadded:: 2.2
        Calls ``current_app.redirect`` if available instead of always
        using Werkzeug's default ``redirect``.
    )rB)rBr)r rÚ _wz_redirect)rArBrrrrrësrzint | BaseResponsez
t.NoReturn)rBr#r$rcOs*trtj|f|ž|Žt|f|ž|ŽdS)aJRaise an :exc:`~werkzeug.exceptions.HTTPException` for the given
    status code.
 
    If :data:`~flask.current_app` is available, it will call its
    :attr:`~flask.Flask.aborter` object, otherwise it will use
    :func:`werkzeug.exceptions.abort`.
 
    :param code: The status code for the exception, which must be
        registered in ``app.aborter``.
    :param args: Passed to the exception.
    :param kwargs: Passed to the exception.
 
    .. versionadded:: 2.2
        Calls ``current_app.aborter`` if available instead of always
        using Werkzeug's default ``abort``.
    N)r ZaborterÚ    _wz_abort)rBr#r$rrrrsr)Ú template_nameÚ    attributercCsttj |¡j|ƒS)aXLoads a macro (or variable) a template exports.  This can be used to
    invoke a macro from within Python code.  If you for example have a
    template named :file:`_cider.html` with the following contents:
 
    .. sourcecode:: html+jinja
 
       {% macro hello(name) %}Hello {{ name }}!{% endmacro %}
 
    You can access this from Python code like this::
 
        hello = get_template_attribute('_cider.html', 'hello')
        return hello('World')
 
    .. versionadded:: 0.2
 
    :param template_name: the name of the template
    :param attribute: the name of the variable of macro to access
    )Úgetattrr Z    jinja_envZ get_templateÚmodule)rErFrrrÚget_template_attributesrIÚmessageÚNone)rJÚcategoryrcCsBt dg¡}| ||f¡|td<t ¡}tj||j||ddS)a˜Flashes a message to the next request.  In order to remove the
    flashed message from the session and to display it to the user,
    the template has to call :func:`get_flashed_messages`.
 
    .. versionchanged:: 0.3
       `category` parameter added.
 
    :param message: the message to be flashed.
    :param category: the category for the message.  The following values
                     are recommended: ``'message'`` for any kind of message,
                     ``'error'`` for errors, ``'info'`` for information
                     messages and ``'warning'`` for warnings.  However any
                     kind of string can be used as category.
    Ú_flashes)Z_async_wrapperrJrLN)rrÚappendr Z_get_current_objectrÚsendZ ensure_sync)rJrLÚflashesZapprrrÚflash0s ürQFrzt.Iterable[str]z!list[str] | list[tuple[str, str]])Úwith_categoriesÚcategory_filterrcsZtj}|dkr*dtkr t d¡ng}|t_ˆrDtt‡fdd„|ƒƒ}|sVdd„|DƒS|S)aöPulls all flashed messages from the session and returns them.
    Further calls in the same request to the function will return
    the same messages.  By default just the messages are returned,
    but when `with_categories` is set to ``True``, the return value will
    be a list of tuples in the form ``(category, message)`` instead.
 
    Filter the flashed messages to one or more categories by providing those
    categories in `category_filter`.  This allows rendering categories in
    separate html blocks.  The `with_categories` and `category_filter`
    arguments are distinct:
 
    * `with_categories` controls whether categories are returned with message
      text (``True`` gives a tuple, where ``False`` gives just the message text).
    * `category_filter` filters the messages down to only those matching the
      provided categories.
 
    See :doc:`/patterns/flashing` for examples.
 
    .. versionchanged:: 0.3
       `with_categories` parameter added.
 
    .. versionchanged:: 0.9
        `category_filter` parameter added.
 
    :param with_categories: set to ``True`` to also receive categories.
    :param category_filter: filter of categories to limit return values.  Only
                            categories in the list will be returned.
    NrMcs |dˆkS)Nrr)Úf©rSrrÚ<lambda>vóz&get_flashed_messages.<locals>.<lambda>cSsg|] }|d‘qS)r    r)Ú.0ÚxrrrÚ
<listcomp>xsz(get_flashed_messages.<locals>.<listcomp>)r rPrÚpopÚlistÚfilter)rRrSrPrrUrÚget_flashed_messagesRsr^zdict[str, t.Any])r$rcKs:| d¡dkrtj|d<|jtjtjdtjtjd|S)NÚmax_ageZUSE_X_SENDFILE)rZuse_x_sendfiler1Z
_root_path)    rr Zget_send_file_max_ageÚupdater rÚconfigr1Ú    root_path)r$rrrÚ_prepare_send_file_kwargs|s
ürczos.PathLike | str | t.BinaryIOz
bool | strzdatetime | int | float | Nonez3None | (int | t.Callable[[str | None], int | None]))    Ú path_or_fileÚmimetypeÚ as_attachmentÚ download_nameÚ conditionalÚetagÚ last_modifiedr_rc Cs&tjjft|tj|||||||d    ŽS)abSend the contents of a file to the client.
 
    The first argument can be a file path or a file-like object. Paths
    are preferred in most cases because Werkzeug can manage the file and
    get extra information from the path. Passing a file-like object
    requires that the file is opened in binary mode, and is mostly
    useful when building a file in memory with :class:`io.BytesIO`.
 
    Never pass file paths provided by a user. The path is assumed to be
    trusted, so a user could craft a path to access a file you didn't
    intend. Use :func:`send_from_directory` to safely serve
    user-requested paths from within a directory.
 
    If the WSGI server sets a ``file_wrapper`` in ``environ``, it is
    used, otherwise Werkzeug's built-in wrapper is used. Alternatively,
    if the HTTP server supports ``X-Sendfile``, configuring Flask with
    ``USE_X_SENDFILE = True`` will tell the server to send the given
    path, which is much more efficient than reading it in Python.
 
    :param path_or_file: The path to the file to send, relative to the
        current working directory if a relative path is given.
        Alternatively, a file-like object opened in binary mode. Make
        sure the file pointer is seeked to the start of the data.
    :param mimetype: The MIME type to send for the file. If not
        provided, it will try to detect it from the file name.
    :param as_attachment: Indicate to a browser that it should offer to
        save the file instead of displaying it.
    :param download_name: The default name browsers will use when saving
        the file. Defaults to the passed file name.
    :param conditional: Enable conditional and range responses based on
        request headers. Requires passing a file path and ``environ``.
    :param etag: Calculate an ETag for the file, which requires passing
        a file path. Can also be a string to use instead.
    :param last_modified: The last modified time to send for the file,
        in seconds. If not provided, it will try to detect it from the
        file path.
    :param max_age: How long the client should cache the file, in
        seconds. If set, ``Cache-Control`` will be ``public``, otherwise
        it will be ``no-cache`` to prefer conditional caching.
 
    .. versionchanged:: 2.0
        ``download_name`` replaces the ``attachment_filename``
        parameter. If ``as_attachment=False``, it is passed with
        ``Content-Disposition: inline`` instead.
 
    .. versionchanged:: 2.0
        ``max_age`` replaces the ``cache_timeout`` parameter.
        ``conditional`` is enabled and ``max_age`` is not set by
        default.
 
    .. versionchanged:: 2.0
        ``etag`` replaces the ``add_etags`` parameter. It can be a
        string to use instead of generating one.
 
    .. versionchanged:: 2.0
        Passing a file-like object that inherits from
        :class:`~io.TextIOBase` will raise a :exc:`ValueError` rather
        than sending an empty file.
 
    .. versionadded:: 2.0
        Moved the implementation to Werkzeug. This is now a wrapper to
        pass some Flask-specific arguments.
 
    .. versionchanged:: 1.1
        ``filename`` may be a :class:`~os.PathLike` object.
 
    .. versionchanged:: 1.1
        Passing a :class:`~io.BytesIO` object supports range requests.
 
    .. versionchanged:: 1.0.3
        Filenames are encoded with ASCII instead of Latin-1 for broader
        compatibility with WSGI servers.
 
    .. versionchanged:: 1.0
        UTF-8 filenames as specified in :rfc:`2231` are supported.
 
    .. versionchanged:: 0.12
        The filename is no longer automatically inferred from file
        objects. If you want to use automatic MIME and etag support,
        pass a filename via ``filename_or_fp`` or
        ``attachment_filename``.
 
    .. versionchanged:: 0.12
        ``attachment_filename`` is preferred over ``filename`` for MIME
        detection.
 
    .. versionchanged:: 0.9
        ``cache_timeout`` defaults to
        :meth:`Flask.get_send_file_max_age`.
 
    .. versionchanged:: 0.7
        MIME guessing and etag support for file-like objects was
        deprecated because it was unreliable. Pass a filename if you are
        able to, otherwise attach an etag yourself.
 
    .. versionchanged:: 0.5
        The ``add_etags``, ``cache_timeout`` and ``conditional``
        parameters were added. The default behavior is to add etags.
 
    .. versionadded:: 0.2
    )    rdrrerfrgrhrirjr_)ÚwerkzeugÚutilsÚ    send_filercr r)rdrerfrgrhrirjr_rrrrm‰so÷ÿrmzos.PathLike | str)Ú    directoryÚpathr$rcKstjj||ftf|ŽŽS)a°Send a file from within a directory using :func:`send_file`.
 
    .. code-block:: python
 
        @app.route("/uploads/<path:name>")
        def download_file(name):
            return send_from_directory(
                app.config['UPLOAD_FOLDER'], name, as_attachment=True
            )
 
    This is a secure way to serve files from a folder, such as static
    files or uploads. Uses :func:`~werkzeug.security.safe_join` to
    ensure the path coming from the client is not maliciously crafted to
    point outside the specified directory.
 
    If the final path does not point to an existing regular file,
    raises a 404 :exc:`~werkzeug.exceptions.NotFound` error.
 
    :param directory: The directory that ``path`` must be located under,
        relative to the current application's root path.
    :param path: The path to the file to send, relative to
        ``directory``.
    :param kwargs: Arguments to pass to :func:`send_file`.
 
    .. versionchanged:: 2.0
        ``path`` replaces the ``filename`` parameter.
 
    .. versionadded:: 2.0
        Moved the implementation to Werkzeug. This is now a wrapper to
        pass some Flask-specific arguments.
 
    .. versionadded:: 0.5
    )rkrlÚsend_from_directoryrc)rnror$rrrrps &ÿÿrp)Ú import_namercCsÀtj |¡}|dk    r>t|dƒr>|jdk    r>tj tj |j¡¡St     
|¡}|dksX|dkr`t  ¡St|dƒrv|  |¡}n6t |ƒtj|}t|ddƒ}|dkr¬td|›dƒ‚tj tj |¡¡S)zìFind the root path of a package, or the path that contains a
    module. If it cannot be found, returns the current working
    directory.
 
    Not to be confused with the value returned by :func:`find_package`.
 
    :meta private:
    NÚ__file__Ú__main__Ú get_filenamez2No root path can be found for the provided module zÊ. This can happen because the module came from an import hook that does not provide file name information or because it's a namespace package. In this case the root path needs to be explicitly provided.)ÚsysÚmodulesrr+rrrroÚdirnameÚabspathÚpkgutilÚ
get_loaderÚgetcwdrtÚ
__import__rGr*)rqÚmodÚloaderÚfilepathrrrÚ get_root_path2s 
 
 
 
 
ÿ
r€cspeZdZdZddddddœ‡fdd„ Zdd    d
d d œ‡fd d„ Zd    d ddœ‡fdd„ Zd    ddœ‡fdd„ Z‡ZS)Úlocked_cached_propertya‚A :func:`property` that is only evaluated once. Like
    :class:`werkzeug.utils.cached_property` except access uses a lock
    for thread safety.
 
    .. deprecated:: 2.3
        Will be removed in Flask 2.4. Use a lock inside the decorated function if
        locking is needed.
 
    .. versionchanged:: 2.0
        Inherits from Werkzeug's ``cached_property`` (and ``property``).
    Nzt.Callable[[t.Any], t.Any]r:rK)ÚfgetÚnameÚdocrcs6ddl}|jdtddtƒj|||dtƒ|_dS)Nrz‡'locked_cached_property' is deprecated and will be removed in Flask 2.4. Use a lock inside the decorated function if locking is needed.é©Ú
stacklevel)rƒr„)ÚwarningsÚwarnÚDeprecationWarningÚsuperÚ__init__rÚlock)Úselfr‚rƒr„rˆ©Ú    __class__rrrŒpsüzlocked_cached_property.__init__ÚobjectÚtyper")Úobjr’rc
s:|dkr |S|jtƒj||dW5QR£SQRXdS)N)r’)rr‹Ú__get__)rŽr“r’rrrr”szlocked_cached_property.__get__)r“Úvaluerc    s$|jtƒ ||¡W5QRXdSr%)rr‹Ú__set__)rŽr“r•rrrr–ˆszlocked_cached_property.__set__)r“rc    s"|jtƒ |¡W5QRXdSr%)rr‹Ú
__delete__)rŽr“rrrr—Œsz!locked_cached_property.__delete__)NN)N)    Ú__name__Ú
__module__Ú __qualname__Ú__doc__rŒr”r–r—Ú __classcell__rrrrrcsür)r•rc    CsRtjdtddtjtjfD]0}zt ||¡Wntk
rDYqXdSqdS)zéDetermine if the given string is an IP address.
 
    :param value: value to check
    :type value: str
 
    :return: True if string is an IP address
    :rtype: bool
 
    .. deprecated:: 2.3
        Will be removed in Flask 2.4.
    zDThe 'is_ip' function is deprecated and will be removed in Flask 2.4.r…r†TF)rˆr‰rŠÚsocketÚAF_INETÚAF_INET6Ú    inet_ptonÚOSError)r•ÚfamilyrrrÚis_ip‘s ýr£)Úmaxsizez    list[str])rƒrcCs*|g}d|kr&| t| d¡dƒ¡|S)NÚ.r)ÚextendÚ_split_blueprint_pathÚ
rpartition)rƒÚoutrrrr§®sr§)T)r>N)rJ)Fr)NFNTTNN)4Ú
__future__rrryrruÚtypingÚtrˆrÚ    functoolsrrÚ    threadingrZwerkzeug.utilsrkZwerkzeug.exceptionsrrDrrCÚglobalsr
r r r rZsignalsrÚ TYPE_CHECKINGZwerkzeug.wrappersrr@Úwrappersrr r&r3r=rIrQr^rcrmrpr€rlÚcached_propertyrr£r§rrrrÚ<module>sn               O4ú7ÿ#ÿ*ø ~+1.