
    5h                        S SK Jr  S SKrS SKrS SKrS SKJrJ	r	J
r
  S SKJr  S SKJrJr  SSKJrJr  SS	KJrJrJr  / S
Qr " S S5      rSSSS.             SS jjr S       SS jjrg)    )annotationsN)AnyCallableLiteral)NotFound)MapRequestRedirect   )RequestResponse   )ServerServerConnectionserve)route
unix_routeRouterc                  v    \ rS rSrSr  S       SS jjrSS jrSS jrSS jr      SS jr	SS	 jr
S
rg)r      z*WebSocket router supporting :func:`route`.Nc                x    Xl         X l        X0l        U R                   R                  5        H
  nSUl        M     g )NT)url_mapserver_name
url_scheme
iter_rules	websocket)selfr   r   r   rules        a/var/www/html/cementerio_25MayoBackend/env/lib/python3.13/site-packages/websockets/sync/router.py__init__Router.__init__   s2     &$LL++-D!DN .    c                R    U R                   c  UR                  S   $ U R                   $ )NHost)r   headers)r   
connectionrequests      r   get_server_nameRouter.get_server_name!   s)    #??6**###r!   c                |    UR                  [        R                  R                  SU 35      nX#R                  S'   U$ )Nz	Found at Location)respondhttp
HTTPStatusFOUNDr$   )r   r%   urlresponses       r   redirectRouter.redirect'   s8    %%doo&;&;y=NO'*$r!   c                V    UR                  [        R                  R                  S5      $ )Nz	Not Found)r+   r,   r-   	NOT_FOUNDr   r%   s     r   	not_foundRouter.not_found,   s    !!$//";";[IIr!   c                   U R                   R                  U R                  X5      U R                  S9n [        R
                  R                  UR                  5      nUR                  UR                  UR                  S9u  pVXVsUl        Ul        g! [         a%  nU R                  XR                  5      s SnA$ SnAf[         a    U R                  U5      s $ f = f)zRoute incoming request.)r   r   )	path_info
query_argsN)r   bindr'   r   urllibparseurlparsepathmatchqueryr	   r1   new_urlr   r6   handlerhandler_kwargs)r   r%   r&   url_map_adapterparsedrC   kwargsr1   s           r   route_requestRouter.route_request/   s     ,,++,,ZA , 
		.\\**7<<8F-33 ++!<< 4 OG 9@5
J5  	?==-=-=>> 	.>>*--	.s$   AB 
CB=7C=CCc                <    UR                   " U40 UR                  D6$ )zHandle a connection.)rC   rD   r5   s     r   rC   Router.handlerD   s    !!*J
0I0IJJr!   )r   r   r   )Nws)r   r   r   
str | Noner   strreturnNone)r%   r   r&   r   rO   rN   )r%   r   r/   rN   rO   r   )r%   r   rO   r   r%   r   r&   r   rO   zResponse | None)r%   r   rO   rP   )__name__
__module____qualname____firstlineno____doc__r   r'   r1   r6   rH   rC   __static_attributes__ r!   r   r   r      sk    4
 #'	
"
"  
" 	
"
 

"$
J*5<	*Kr!   r   )r   sslcreate_routerc                  ^^	 Uc  SOSnUSLa  Ub  X%S'   Uc  [         nU" XU5      m	UR                  SS5      mTc  T	R                  nO      SUU	4S jjn[        T	R                  /UQ7SU0UD6$ )	a  
Create a WebSocket server dispatching connections to different handlers.

This feature requires the third-party library `werkzeug`_:

.. code-block:: console

    $ pip install werkzeug

.. _werkzeug: https://werkzeug.palletsprojects.com/

:func:`route` accepts the same arguments as
:func:`~websockets.sync.server.serve`, except as described below.

The first argument is a :class:`werkzeug.routing.Map` that maps URL patterns
to connection handlers. In addition to the connection, handlers receive
parameters captured in the URL as keyword arguments.

Here's an example::


    from websockets.sync.router import route
    from werkzeug.routing import Map, Rule

    def channel_handler(websocket, channel_id):
        ...

    url_map = Map([
        Rule("/channel/<uuid:channel_id>", endpoint=channel_handler),
        ...
    ])

    with route(url_map, ...) as server:
        server.serve_forever()

Refer to the documentation of :mod:`werkzeug.routing` for details.

If you define redirects with ``Rule(..., redirect_to=...)`` in the URL map,
when the server runs behind a reverse proxy that modifies the ``Host``
header or terminates TLS, you need additional configuration:

* Set ``server_name`` to the name of the server as seen by clients. When not
  provided, websockets uses the value of the ``Host`` header.

* Set ``ssl=True`` to generate ``wss://`` URIs without actually enabling
  TLS. Under the hood, this bind the URL map with a ``url_scheme`` of
  ``wss://`` instead of ``ws://``.

There is no need to specify ``websocket=True`` in each rule. It is added
automatically.

Args:
    url_map: Mapping of URL patterns to connection handlers.
    server_name: Name of the server as seen by clients. If :obj:`None`,
        websockets uses the value of the ``Host`` header.
    ssl: Configuration for enabling TLS on the connection. Set it to
        :obj:`True` if a reverse proxy terminates TLS connections.
    create_router: Factory for the :class:`Router` dispatching requests to
        handlers. Set it to a wrapper or a subclass to customize routing.

NrL   wssTrY   process_requestc                @   > T" X5      nUb  U$ TR                  X5      $ N)rH   )r%   r&   r0   _process_requestrouters      r   r]   route.<locals>.process_request   s+     (
<H#''
<<r!   rQ   )r   poprH   r   rC   )
r   r   rY   rZ   argsrG   r   r]   r`   ra   s
           @@r   r   r   I   s    J %J
$3?u7<F 	

$d+      		=(	=3:	=	= 	= R$RR6RRr!   c                     [        U 4SUS.UD6$ )a/  
Create a WebSocket Unix server dispatching connections to different handlers.

:func:`unix_route` combines the behaviors of :func:`route` and
:func:`~websockets.sync.server.unix_serve`.

Args:
    url_map: Mapping of URL patterns to connection handlers.
    path: File system path to the Unix socket.

T)unixr?   )r   )r   r?   rG   s      r   r   r      s      9t$9&99r!   )r   r   rd   r   r   rM   rY   z,ssl_module.SSLContext | Literal[True] | NonerZ   ztype[Router] | NonerG   r   rO   r   r_   )r   r   r?   rM   rG   r   rO   r   )
__future__r   r,   rY   
ssl_moduleurllib.parser<   typingr   r   r   werkzeug.exceptionsr   werkzeug.routingr   r	   http11r   r   serverr   r   r   __all__r   r   r   rX   r!   r   <module>rp      s    "    ) ) ( 1 & 3 3 ,4K 4Kt #8<)-dSdSdS dS 
6	dS
 'dS dS dSR ::
: : 	:r!   