
    i                     P    d dl Z d dlmZ  G d d          Z G d de          ZdS )    N)get_static_filec                   *    e Zd ZdZ	 	 ddZd Zd ZdS )WSGIAppa  WSGI application middleware for Engine.IO.

    This middleware dispatches traffic to an Engine.IO application. It can
    also serve a list of static files to the client, or forward unrelated
    HTTP traffic to another WSGI application.

    :param engineio_app: The Engine.IO server. Must be an instance of the
                         ``engineio.Server`` class.
    :param wsgi_app: The WSGI app that receives all other traffic.
    :param static_files: A dictionary with static file mapping rules. See the
                         documentation for details on this argument.
    :param engineio_path: The endpoint where the Engine.IO application should
                          be installed. The default value is appropriate for
                          most cases.

    Example usage::

        import engineio
        import eventlet

        eio = engineio.Server()
        app = engineio.WSGIApp(eio, static_files={
            '/': {'content_type': 'text/html', 'filename': 'index.html'},
            '/index.html': {'content_type': 'text/html',
                            'filename': 'index.html'},
        })
        eventlet.wsgi.server(eventlet.listen(('', 8000)), app)
    N	engine.ioc                     || _         || _        || _        | j                            d          sd| j        z   | _        | j                            d          s| xj        dz  c_        |pi | _        d S )N/)engineio_appwsgi_appengineio_path
startswithendswithstatic_files)selfr	   r
   r   r   s        >/usr/local/lib/python3.11/dist-packages/engineio/middleware.py__init__zWSGIApp.__init__"   s    ( *!,,S11 	:!$t'9!9D!**3// 	&#%(.B    c                 j   d|v r! G d d          } ||d                   |d<   |d         }|5|                     | j                  r| j                            ||          S | j        rt          || j                  nd }|r~t          j                            |d                   rY |dd|d	         fg           t          |d         d
          5 }|
                                gcd d d            S # 1 swxY w Y   n| j        |                     ||          S |                     |          S )Nzgunicorn.socketc                       e Zd Zd Zd ZdS )WSGIApp.__call__.<locals>.Inputc                     || _         d S Nsocket)r   r   s     r   r   z(WSGIApp.__call__.<locals>.Input.__init__6   s    "(DKKKr   c                     | j         S r   r   )r   s    r   
get_socketz*WSGIApp.__call__.<locals>.Input.get_socket9   s
    ;&r   N)__name__
__module____qualname__r   r    r   r   Inputr   5   s2        ) ) )' ' ' ' 'r   r    zeventlet.input	PATH_INFOfilenamez200 OKContent-Typecontent_typerb)r   r   r	   handle_requestr   r   ospathexistsopenreadr
   	not_found)r   environstart_responser    r(   static_filefs          r   __call__zWSGIApp.__call__-   s   ''' ' ' ' ' ' ' ' ).g6G.H(I(IG$%{#0B C C$33G^LLL $//$0ABBB*.  >rw~~k*.EFF >$k.&ABCE E E +j1488 &AFFHH:& & & & & & & & & & & & & & & & &*}}Wn===~~n---s   C77C;>C;c                 "     |ddg           dgS )Nz404 Not Found)r#   z
text/plains	   Not Foundr   )r   r.   s     r   r,   zWSGIApp.not_foundM   s     )G(HIII~r   )NNr   )r   r   r   __doc__r   r1   r,   r   r   r   r   r      s[         8 BF*	/ 	/ 	/ 	/. . .@    r   r   c                   (     e Zd ZdZ	 	 d fd	Z xZS )
MiddlewarezAThis class has been renamed to ``WSGIApp`` and is now deprecated.Nr   c                 P    t                                          |||           d S )N)r   )superr   )r   r	   r
   r   	__class__s       r   r   zMiddleware.__init__T   s(    x}MMMMMr   )Nr   )r   r   r   r3   r   __classcell__)r8   s   @r   r5   r5   R   sS        KK.2*N N N N N N N N N Nr   r5   )r'   engineio.static_filesr   r   r5   r   r   r   <module>r;      s    				 1 1 1 1 1 1J J J J J J J JZN N N N N N N N N Nr   