a
    d=ic¶
  ã                   @   s$   d Z ddlmZ G dd„ deƒZdS )zîInternal path prefix support for TensorBoard.

Using a path prefix of `/foo/bar` enables TensorBoard to serve from
`http://localhost:6006/foo/bar/` rather than `http://localhost:6006/`.
See the `--path_prefix` flag docs for more details.
é    )Úerrorsc                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚPathPrefixMiddlewareaX  WSGI middleware for path prefixes.

    All requests to this middleware must begin with the specified path
    prefix (otherwise, a 404 will be returned immediately). Requests
    will be forwarded to the underlying application with the path prefix
    stripped and appended to `SCRIPT_NAME` (see the WSGI spec, PEP 3333,
    for details).
    c                 C   sL   |  d¡rtd| ƒ‚|r0| d¡s0td| ƒ‚|| _|| _| jd | _dS )ax  Initializes this middleware.

        Args:
          application: The WSGI application to wrap (see PEP 3333).
          path_prefix: A string path prefix to be stripped from incoming
            requests. If empty, this middleware is a no-op. If non-empty,
            the path prefix must start with a slash and not end with one
            (e.g., "/tensorboard").
        ú/z'Path prefix must not end with slash: %rz/Non-empty path prefix must start with slash: %rN)ÚendswithÚ
ValueErrorÚ
startswithÚ_applicationÚ_path_prefixÚ_strict_prefix)ÚselfZapplicationZpath_prefix© r   úp/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/tensorboard/backend/path_prefix.pyÚ__init__$   s    

ÿÿzPathPrefixMiddleware.__init__c                 C   sb   |  dd¡}|| jkr*| | j¡s*t ¡ ‚|t| jƒd … |d< |  dd¡| j |d< |  ||¡S )NZ	PATH_INFOÚ ZSCRIPT_NAME)Úgetr	   r   r
   r   ZNotFoundErrorÚlenr   )r   ÚenvironZstart_responseÚpathr   r   r   Ú__call__:   s    ÿÿzPathPrefixMiddleware.__call__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r      s   	r   N)r   Ztensorboardr   Úobjectr   r   r   r   r   Ú<module>   s   