Ë
    ðLqj)  ã                  óP  — d dl mZ d dlZd dlZd dlmZmZmZ d dlm	Z	m
Z
mZ ej                  dk\  rd dlmZ nd dlmZ d dlmZmZ d dlmZmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZ d dlm Z m!Z! d dl"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z( d dl)m*Z*  edd¬«      Z+ ed«      Z, G d„ d«      Z-y)é    )ÚannotationsN)Ú	AwaitableÚMappingÚSequence)ÚAnyÚCallableÚTypeVar)é   é
   )Ú	ParamSpec)ÚStateÚURLPath)Ú
MiddlewareÚ_MiddlewareFactory)ÚBaseHTTPMiddleware)ÚServerErrorMiddleware)ÚExceptionMiddleware)ÚRequest)ÚResponse)Ú	BaseRouteÚRouter)ÚASGIAppÚExceptionHandlerÚLifespanÚReceiveÚScopeÚSend)Ú	WebSocketÚAppTypeÚ	Starlette)ÚboundÚPc                  óL  — e Zd ZdZ	 	 	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd„Zdd„Zedd„«       Zdd„Zdd„Z	dd„Z
ddd	„Zddd
„Z	 	 	 	 	 	 	 	 dd„Z	 	 	 	 	 	 dd„Z	 	 	 	 	 	 d d„Z	 	 	 d!	 	 	 	 	 	 	 	 	 	 	 d"d„Z	 d	 	 	 	 	 	 	 d#d„Zd$d„Z	 	 	 d!	 	 	 	 	 	 	 	 	 d%d„Zdd&d„Zd'd„Zy)(r    z!Creates an Starlette application.Nc                óÐ   — |�|€|�J d«       ‚|| _         t        «       | _        t        ||||¬«      | _        |€i n
t        |«      | _        |€g n
t        |«      | _        d| _	        y)aø  Initializes the application.

        Parameters:
            debug: Boolean indicating if debug tracebacks should be returned on errors.
            routes: A list of routes to serve incoming HTTP and WebSocket requests.
            middleware: A list of middleware to run for every request. A starlette
                application will always automatically include two middleware classes.
                `ServerErrorMiddleware` is added as the very outermost middleware, to handle
                any uncaught errors occurring anywhere in the entire stack.
                `ExceptionMiddleware` is added as the very innermost middleware, to deal
                with handled exception cases occurring in the routing or endpoints.
            exception_handlers: A mapping of either integer status codes,
                or exception class types onto callables which handle the exceptions.
                Exception handler callables should be of the form
                `handler(request, exc) -> response` and may be either standard functions, or
                async functions.
            on_startup: A list of callables to run on application startup.
                Startup handler callables do not take any arguments, and may be either
                standard functions, or async functions.
            on_shutdown: A list of callables to run on application shutdown.
                Shutdown handler callables do not take any arguments, and may be either
                standard functions, or async functions.
            lifespan: A lifespan context function, which can be used to perform
                startup and shutdown tasks. This is a newer style that replaces the
                `on_startup` and `on_shutdown` handlers. Use one or the other, not both.
        Nz>Use either 'lifespan' or 'on_startup'/'on_shutdown', not both.)Ú
on_startupÚon_shutdownÚlifespan)
Údebugr   Ústater   ÚrouterÚdictÚexception_handlersÚlistÚuser_middlewareÚmiddleware_stack)Úselfr(   ÚroutesÚ
middlewarer,   r%   r&   r'   s           úb/var/www/html/ai-menu-system/python-ai/venv/lib/python3.12/site-packages/starlette/applications.pyÚ__init__zStarlette.__init__   s{   € ðL Ð JÐ$6¸;Ð;Nð 	
ØLó	
ÐOð ˆŒ
Ü“WˆŒ
Ü˜V°
ÈÐ^fÔgˆŒØ(:Ð(B¡"ÌÐM_ÓH`ˆÔØ%/Ð%7™r¼TÀ*Ó=MˆÔØ04ˆÕó    c                óN  — | j                   }d }i }| j                  j                  «       D ]  \  }}|dt        fv r|}Œ|||<   Œ t	        t
        ||¬«      g| j                  z   t	        t        ||¬«      gz   }| j                  }t        |«      D ]  \  }}	}
 ||g|	¢­i |
¤Ž}Œ |S )Niô  )Úhandlerr(   )Úhandlersr(   )
r(   r,   ÚitemsÚ	Exceptionr   r   r.   r   r*   Úreversed)r0   r(   Úerror_handlerr,   ÚkeyÚvaluer2   ÚappÚclsÚargsÚkwargss              r3   Úbuild_middleware_stackz Starlette.build_middleware_stackP   sÑ   € Ø—
‘
ˆØˆØ:<Ðà×1Ñ1×7Ñ7Ó9ò 	0‰JˆC�Ø�sœIÐ&Ñ&Ø %‘à*/Ð" 3Ò'ð		0ô Ô-°}ÈEÔRÐSØ×"Ñ"ñ#äÔ-Ð8JÐRWÔXÐYñZð 	ð �k‰kˆÜ!)¨*Ó!5ò 	,ÑˆC��vÙ�cÐ+˜DÒ+ FÑ+‰Cð	,àˆ
r5   c                ó.   — | j                   j                  S ©N)r*   r1   )r0   s    r3   r1   zStarlette.routesf   s   € à�{‰{×!Ñ!Ð!r5   c               ó<   —  | j                   j                  |fi |¤ŽS rE   )r*   Úurl_path_for)r0   ÚnameÚpath_paramss      r3   rG   zStarlette.url_path_forj   s   € Ø'ˆt�{‰{×'Ñ'¨Ñ<°Ñ<Ð<r5   c              ƒ  ó’   K  — | |d<   | j                   €| j                  «       | _         | j                  |||«      ƒ d {  –—†  y 7 Œ­w)Nr?   )r/   rC   )r0   ÚscopeÚreceiveÚsends       r3   Ú__call__zStarlette.__call__m   sD   è ø€ Øˆˆe‰Ø× Ñ Ð(Ø$(×$?Ñ$?Ó$AˆDÔ!Ø×#Ñ# E¨7°DÓ9×9Ò9ús   ‚=A¿AÁ Ac                ó8   — | j                   j                  |«      S rE   )r*   Úon_event)r0   Ú
event_types     r3   rP   zStarlette.on_events   s   € Ø�{‰{×#Ñ# JÓ/Ð/r5   c                ó@   — | j                   j                  |||¬«       y ©N)r?   rH   )r*   Úmount)r0   Úpathr?   rH   s       r3   rT   zStarlette.mountv   s   € Ø�‰×Ñ˜$ C¨dÐÕ3r5   c                ó@   — | j                   j                  |||¬«       y rS   )r*   Úhost)r0   rW   r?   rH   s       r3   rW   zStarlette.hosty   s   € Ø�‰×Ñ˜ 3¨TÐÕ2r5   c                ó„   — | j                   �t        d«      ‚| j                  j                  dt	        |g|¢­i |¤Ž«       y )Nz6Cannot add middleware after an application has startedr   )r/   ÚRuntimeErrorr.   Úinsertr   )r0   Úmiddleware_classrA   rB   s       r3   Úadd_middlewarezStarlette.add_middleware|   sB   € ð × Ñ Ð,ÜÐWÓXÐXØ×Ñ×#Ñ# A¤zÐ2BÐ'TÀTÒ'TÈVÑ'TÕUr5   c                ó"   — || j                   |<   y rE   )r,   )r0   Úexc_class_or_status_coder7   s      r3   Úadd_exception_handlerzStarlette.add_exception_handler†   s   € ð
 =Dˆ×ÑÐ 8Ò9r5   c                ó<   — | j                   j                  ||«       y rE   )r*   Úadd_event_handler)r0   rQ   Úfuncs      r3   ra   zStarlette.add_event_handler�   s   € ð
 	�‰×%Ñ% j°$Õ7r5   c                óD   — | j                   j                  |||||¬«       y ©N)ÚmethodsrH   Úinclude_in_schema©r*   Ú	add_route)r0   rU   Úroutere   rH   rf   s         r3   rh   zStarlette.add_route”   s"   € ð 	�‰×Ñ˜d E°7ÀÐYjÐÕkr5   c                ó@   — | j                   j                  |||¬«       y ©N)rH   ©r*   Úadd_websocket_route)r0   rU   ri   rH   s       r3   rm   zStarlette.add_websocket_routež   s   € ð 	�‰×'Ñ'¨¨e¸$Ð'Õ?r5   c                óL   ‡ ‡— t        j                  dt        «       dˆˆ fd„}|S )Nz¢The `exception_handler` decorator is deprecated, and will be removed in version 1.0.0. Refer to https://www.starlette.io/exceptions/ for the recommended approach.c                ó,   •— ‰j                  ‰| «       | S rE   )r_   )rb   r^   r0   s    €€r3   Ú	decoratorz.Starlette.exception_handler.<locals>.decorator­   s   ø€ Ø×&Ñ&Ð'?ÀÔFØˆKr5   ©rb   r   Úreturnr   ©ÚwarningsÚwarnÚDeprecationWarning)r0   r^   rp   s   `` r3   Úexception_handlerzStarlette.exception_handler¦   s%   ù€ Ü�‰ðZäô	
ö	ð Ðr5   c                óX   ‡ ‡‡‡‡— t        j                  dt        «       dˆˆˆˆˆ fd„}|S )zø
        We no longer document this decorator style API, and its usage is discouraged.
        Instead you should use the following approach:

        >>> routes = [Route(path, endpoint=...), ...]
        >>> app = Starlette(routes=routes)
        z“The `route` decorator is deprecated, and will be removed in version 1.0.0. Refer to https://www.starlette.io/routing/ for the recommended approach.c                óH   •— ‰j                   j                  ‰| ‰‰‰¬«       | S rd   rg   )rb   rf   re   rH   rU   r0   s    €€€€€r3   rp   z"Starlette.route.<locals>.decoratorÇ   s0   ø€ Ø�K‰K×!Ñ!ØØØØØ"3ð "ô ð ˆKr5   rq   rs   )r0   rU   re   rH   rf   rp   s   ````` r3   ri   zStarlette.route³   s,   ü€ ô 	�‰ðWäô	
÷	ñ 	ð Ðr5   c                óP   ‡ ‡‡— t        j                  dt        «       dˆˆˆ fd„}|S )a  
        We no longer document this decorator style API, and its usage is discouraged.
        Instead you should use the following approach:

        >>> routes = [WebSocketRoute(path, endpoint=...), ...]
        >>> app = Starlette(routes=routes)
        z¯The `websocket_route` decorator is deprecated, and will be removed in version 1.0.0. Refer to https://www.starlette.io/routing/#websocket-routing for the recommended approach.c                óD   •— ‰j                   j                  ‰| ‰¬«       | S rk   rl   )rb   rH   rU   r0   s    €€€r3   rp   z,Starlette.websocket_route.<locals>.decoratorá   s!   ø€ Ø�K‰K×+Ñ+¨D°$¸TÐ+ÔBØˆKr5   rq   rs   )r0   rU   rH   rp   s   ``` r3   Úwebsocket_routezStarlette.websocket_routeÓ   s'   ú€ ô 	�‰ðiäô	
÷	ð Ðr5   c                ó`   ‡ — t        j                  dt        «       |dk(  sJ d«       ‚dˆ fd„}|S )zú
        We no longer document this decorator style API, and its usage is discouraged.
        Instead you should use the following approach:

        >>> middleware = [Middleware(...), ...]
        >>> app = Starlette(middleware=middleware)
        z¨The `middleware` decorator is deprecated, and will be removed in version 1.0.0. Refer to https://www.starlette.io/middleware/#using-middleware for recommended approach.Úhttpz/Currently only middleware("http") is supported.c                ó6   •— ‰j                  t        | ¬«       | S )N)Údispatch)r\   r   )rb   r0   s    €r3   rp   z'Starlette.middleware.<locals>.decoratorö   s   ø€ Ø×ÑÔ 2¸TÐÔBØˆKr5   rq   rs   )r0   Úmiddleware_typerp   s   `  r3   r2   zStarlette.middlewareç   s=   ø€ ô 	�‰ðgäô	
ð
  &Ò(Ð[Ð*[Ó[Ð(õ	ð Ðr5   )FNNNNNN)r0   r   r(   Úboolr1   zSequence[BaseRoute] | Noner2   zSequence[Middleware] | Noner,   z%Mapping[Any, ExceptionHandler] | Noner%   ú"Sequence[Callable[[], Any]] | Noner&   rƒ   r'   zLifespan[AppType] | Nonerr   ÚNone)rr   r   )rr   zlist[BaseRoute])rH   ÚstrrI   r   rr   r   )rK   r   rL   r   rM   r   rr   r„   )rQ   r…   rr   r   rE   )rU   r…   r?   r   rH   ú
str | Nonerr   r„   )rW   r…   r?   r   rH   r†   rr   r„   )r[   z_MiddlewareFactory[P]rA   zP.argsrB   zP.kwargsrr   r„   )r^   úint | type[Exception]r7   r   rr   r„   )rQ   r…   rb   r   rr   r„   )NNT)rU   r…   ri   z3Callable[[Request], Awaitable[Response] | Response]re   úlist[str] | NonerH   r†   rf   r‚   rr   r„   )rU   r…   ri   z&Callable[[WebSocket], Awaitable[None]]rH   r†   rr   r„   )r^   r‡   rr   r   )
rU   r…   re   rˆ   rH   r†   rf   r‚   rr   r   )rU   r…   rH   r†   rr   r   )r�   r…   rr   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r4   rC   Úpropertyr1   rG   rN   rP   rT   rW   r\   r_   ra   rh   rm   rw   ri   r|   r2   © r5   r3   r    r       sø  „ Ù+ð Ø-1Ø26ØDHØ9=Ø:>Ø-1ð/5Øð/5àð/5ð +ð/5ð 0ð	/5ð
 Bð/5ð 7ð/5ð 8ð/5ð +ð/5ð 
ó/5óbð, ò"ó ð"ó=ó:ó0ô4ô3ðVà/ðVð ðVð ð	Vð
 
óVðDà"7ðDð "ðDð 
ó	Dð8àð8ð ð8ð 
ó	8ð %)ØØ"&ðlàðlð Cðlð "ð	lð
 ðlð  ðlð 
ólð  ð	@àð@ð 6ð@ð ð	@ð
 
ó@óð  %)ØØ"&ðàðð "ðð ð	ð
  ðð 
óô@ô(r5   ).Ú
__future__r   Úsysrt   Úcollections.abcr   r   r   Útypingr   r   r	   Úversion_infor   Útyping_extensionsÚstarlette.datastructuresr   r   Ústarlette.middlewarer   r   Ústarlette.middleware.baser   Ústarlette.middleware.errorsr   Ústarlette.middleware.exceptionsr   Ústarlette.requestsr   Ústarlette.responsesr   Ústarlette.routingr   r   Ústarlette.typesr   r   r   r   r   r   Ústarlette.websocketsr   r   r"   r    rŽ   r5   r3   ú<module>rŸ      sp   ðÝ "ã 
Û ß 8Ñ 8ß )Ñ )à×Ñ�wÒÞ å+ç 3ß ?Ý 8Ý =Ý ?Ý &Ý (ß /ß U× UÝ *á
�) ;Ô
/€ÙˆcƒN€÷^ò ^r5   