| Server IP : 217.160.0.135 / Your IP : 216.73.217.85 Web Server : Apache System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64 User : sws1074145052 ( 1074145052) PHP Version : 8.3.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib/python3/dist-packages/werkzeug/middleware/__pycache__/ |
Upload File : |
�
��b8% � �� � d Z ddlZddlZddlZddlZddlZddlmZ ddlmZ ddl m
Z
ddlmZ ddlm
Z
dd lmZ dd
lmZ ddlmZ ddlmZ dd
lmZ ddlmZ ej g ej ej e eef f Zej ej e gej ej e ej e f f Z ej! rddl"m#Z# ddl"m$Z$ ddl"m%Z% G d� d� � Z&dS )z�
Serve Shared Static Files
=========================
.. autoclass:: SharedDataMiddleware
:members: is_allowed
:copyright: 2007 Pallets
:license: BSD-3-Clause
� N)�datetime)�timezone)�BytesIO)�time)�adler32� )� http_date)�is_resource_modified)� safe_join)�get_content_type)�
get_path_info)� wrap_file)�
StartResponse)�WSGIApplication)�WSGIEnvironmentc � � e Zd ZdZ d!dddej ej eej eej eef f f ej ej eej eej eef f f f d dd
e
deded
dfd�Zded
e
fd�Z
ded
efd�Zded
efd�Zdeded
efd�Zded
efd�Zdededed
efd�Zddddd
ej e fd �ZdS )"�SharedDataMiddlewarea� A WSGI middleware which provides static content for development
environments or simple server setups. Its usage is quite simple::
import os
from werkzeug.middleware.shared_data import SharedDataMiddleware
app = SharedDataMiddleware(app, {
'/shared': os.path.join(os.path.dirname(__file__), 'shared')
})
The contents of the folder ``./shared`` will now be available on
``http://example.com/shared/``. This is pretty useful during development
because a standalone media server is not required. Files can also be
mounted on the root folder and still continue to use the application because
the shared data middleware forwards all unhandled requests to the
application, even if the requests are below one of the shared folders.
If `pkg_resources` is available you can also tell the middleware to serve
files from package data::
app = SharedDataMiddleware(app, {
'/static': ('myapplication', 'static')
})
This will then serve the ``static`` folder in the `myapplication`
Python package.
The optional `disallow` parameter can be a list of :func:`~fnmatch.fnmatch`
rules for files that are not accessible from the web. If `cache` is set to
`False` no caching headers are sent.
Currently the middleware does not support non-ASCII filenames. If the
encoding on the file system happens to match the encoding of the URI it may
work but this could also be by accident. We strongly suggest using ASCII
only file names for static files.
The middleware will guess the mimetype using the Python `mimetype`
module. If it's unable to figure out the charset it will fall back
to `fallback_mimetype`.
:param app: the application to wrap. If you don't want to wrap an
application you can pass it :exc:`NotFound`.
:param exports: a list or dict of exported files and folders.
:param disallow: a list of :func:`~fnmatch.fnmatch` rules.
:param cache: enable or disable caching headers.
:param cache_timeout: the cache timeout in seconds for the headers.
:param fallback_mimetype: The fallback mimetype for unknown files.
.. versionchanged:: 1.0
The default ``fallback_mimetype`` is
``application/octet-stream``. If a filename looks like a text
mimetype, the ``utf-8`` charset is added to it.
.. versionadded:: 0.6
Added ``fallback_mimetype``.
.. versionchanged:: 0.5
Added ``cache_timeout``.
NT� �application/octet-stream�appr �exports�disallow�cache�
cache_timeout�fallback_mimetype�returnc �4 ��
� || _ g | _ || _ || _ t |t
� � r|� � � }|D ]�\ }}t |t � � r | j |� } nrt |t � � rKt j � |� � r| �
|� � } n(| � |� � } nt d|��� � �| j � || f� � ����ddlm�
��
fd�| _ || _ d S )Nzunknown def r )�fnmatchc � �� �| �� � S �N� )�xr r s ���A/usr/lib/python3/dist-packages/werkzeug/middleware/shared_data.py�<lambda>z/SharedDataMiddleware.__init__.<locals>.<lambda>� s �� �G�G�A�x�,@�,@�(@� � )r r r r �
isinstance�dict�items�tuple�get_package_loader�str�os�path�isfile�get_file_loader�get_directory_loader� TypeError�appendr �
is_allowedr )�selfr r r r r r �key�value�loaderr s ` @r# �__init__zSharedDataMiddleware.__init__d s7 ��� � ���79�����
�*����g�t�$�$� &��m�m�o�o�G�!� /� /�J�C���%��'�'�
:�0��0�%�8����E�3�'�'�
:��7�>�>�%�(�(� >�!�1�1�%�8�8�F�F�!�6�6�u�=�=�F�F�� 8�u� 8� 8�9�9�9��L����f�
�.�.�.�.���'�'�'�'�'�'�@�@�@�@�@�D�O�!2����r% �filenamec � � dS )z�Subclasses can override this method to disallow the access to
certain files. However by providing `disallow` in the constructor
this method is overwritten.
Tr! �r4 r9 s r# r3 zSharedDataMiddleware.is_allowed� s � �
�tr% c � �� �fd�S )Nc �� �� t � d� � t j t j � � � � t j �� � t t j � � � � � � fS )N�rb��tz)
�openr �
fromtimestampr, r- �getmtimer �utc�int�getsize)r9 s �r# r$ z.SharedDataMiddleware._opener.<locals>.<lambda>� sU �� ���4� � ��"�2�7�#3�#3�H�#=�#=�(�,�O�O�O�������)�)�*�*�
� r% r! r; s `r# �_openerzSharedDataMiddleware._opener� s �� �
�
�
�
�
r% c � � �� �� fd�S )Nc �l �� t j � �� � �� �� � fS r )r, r- �basenamerG )r"