
    	h)                    \   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-dS )    )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                      e Zd ZdZ	 	 	 	 	 	 	 dLdMdZdNdZedOd            ZdPdZdQd&Z	dRd)Z
dSdTd-ZdSdUd/ZdVd6ZdWd;ZdXd=Z	 	 	 dYdZdDZ	 dSd[dFZd\dGZ	 	 	 dYd]dHZdSd^dIZd_dKZdS )`r    z!Creates an Starlette application.FNselfr   debugboolroutesSequence[BaseRoute] | None
middlewareSequence[Middleware] | Noneexception_handlers%Mapping[Any, ExceptionHandler] | None
on_startup"Sequence[Callable[[], Any]] | Noneon_shutdownlifespanLifespan[AppType] | NonereturnNonec                    |||
J d            || _         t                      | _        t          ||||          | _        |i nt          |          | _        |g nt          |          | _        d| _	        dS )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.)r-   r/   r0   )
r%   r   stater   routerdictr+   listuser_middlewaremiddleware_stack)r$   r%   r'   r)   r+   r-   r/   r0   s           c/var/www/html/web-builder-api.evdpl.com/venv/lib/python3.11/site-packages/starlette/applications.py__init__zStarlette.__init__   s    L J$6;;N;NL <O;NO 
WW
V
^fggg(:(B""M_H`H`%/%7rrT*=M=M04    r   c                D   | j         }d }i }| j                                        D ]\  }}|dt          fv r|}|||<   t	          t
          ||          g| j        z   t	          t          ||          gz   }| j        }t          |          D ]\  }}	}
 ||g|	R i |
}|S )Ni  )handlerr%   )handlersr%   )
r%   r+   items	Exceptionr   r   r9   r   r6   reversed)r$   r%   error_handlerr+   keyvaluer)   appclsargskwargss              r;   build_middleware_stackz Starlette.build_middleware_stackP   s    
:<17799 	0 	0JCsI&&& %*/"3'' -}ERRRS"#-8JRWXXXYZ 	 k!)*!5!5 	, 	,Cv#c+D+++F++CC
r=   list[BaseRoute]c                    | j         j        S N)r6   r'   )r$   s    r;   r'   zStarlette.routesf   s    {!!r=   namestrpath_paramsr   r   c               (     | j         j        |fi |S rN   )r6   url_path_for)r$   rO   rQ   s      r;   rS   zStarlette.url_path_forj   s    't{'<<<<<r=   scoper   receiver   sendr   c                   K   | |d<   | j         |                                 | _         |                      |||           d {V  d S )NrG   )r:   rK   )r$   rT   rU   rV   s       r;   __call__zStarlette.__call__m   s\      e ($($?$?$A$AD!##E7D99999999999r=   
event_typer   c                6    | j                             |          S rN   )r6   on_event)r$   rY   s     r;   r[   zStarlette.on_events   s    {##J///r=   pathrG   
str | Nonec                @    | j                             |||           d S N)rG   rO   )r6   mount)r$   r\   rG   rO   s       r;   r`   zStarlette.mountv   s%    $Cd33333r=   hostc                @    | j                             |||           d S r_   )r6   ra   )r$   ra   rG   rO   s       r;   ra   zStarlette.hosty   s%    3T22222r=   middleware_class_MiddlewareFactory[P]rI   P.argsrJ   P.kwargsc                    | j         t          d          | j                            dt	          |g|R i |           d S )Nz6Cannot add middleware after an application has startedr   )r:   RuntimeErrorr9   insertr   )r$   rc   rI   rJ   s       r;   add_middlewarezStarlette.add_middleware|   sT      ,WXXX##Az2B'TT'T'T'TV'T'TUUUUUr=   exc_class_or_status_codeint | type[Exception]r?   r   c                    || j         |<   d S rN   )r+   )r$   rk   r?   s      r;   add_exception_handlerzStarlette.add_exception_handler   s    
 =D 8999r=   funcc                <    | j                             ||           d S rN   )r6   add_event_handler)r$   rY   ro   s      r;   rq   zStarlette.add_event_handler   s"    
 	%%j$77777r=   Troute3Callable[[Request], Awaitable[Response] | Response]methodslist[str] | Noneinclude_in_schemac                D    | j                             |||||           d S N)rt   rO   rv   r6   	add_route)r$   r\   rr   rt   rO   rv   s         r;   rz   zStarlette.add_route   s,     	dE7Yjkkkkkr=   &Callable[[WebSocket], Awaitable[None]]c                @    | j                             |||           d S N)rO   r6   add_websocket_route)r$   r\   rr   rO   s       r;   r   zStarlette.add_websocket_route   s'     	''e$'?????r=   c                L     t          j        dt                     d fd}|S )NzThe `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.ro   r   r2   c                4                         |            | S rN   )rn   )ro   rk   r$   s    r;   	decoratorz.Starlette.exception_handler.<locals>.decorator   s    &&'?FFFKr=   ro   r   r2   r   warningswarnDeprecationWarning)r$   rk   r   s   `` r;   exception_handlerzStarlette.exception_handler   sL    Z	
 	
 	
	 	 	 	 	 	 	 r=   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)
        zThe `route` decorator is deprecated, and will be removed in version 1.0.0. Refer to https://www.starlette.io/routing/ for the recommended approach.ro   r   r2   c                F    j                             |            | S rx   ry   )ro   rv   rt   rO   r\   r$   s    r;   r   z"Starlette.route.<locals>.decorator   s8    K!!"3 "    Kr=   r   r   )r$   r\   rt   rO   rv   r   s   ````` r;   rr   zStarlette.route   s`     	W	
 	
 	
	 	 	 	 	 	 	 	 	 	 r=   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)
        zThe `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.ro   r   r2   c                B    j                             |            | S r}   r~   )ro   rO   r\   r$   s    r;   r   z,Starlette.websocket_route.<locals>.decorator   s%    K++D$T+BBBKr=   r   r   )r$   r\   rO   r   s   ``` r;   websocket_routezStarlette.websocket_route   sT     	i	
 	
 	
	 	 	 	 	 	 	 	 r=   middleware_typec                h     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)
        zThe `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.ro   r   r2   c                @                         t          |            | S )N)dispatch)rj   r   )ro   r$   s    r;   r   z'Starlette.middleware.<locals>.decorator   s"     2TBBBKr=   r   r   )r$   r   r   s   `  r;   r)   zStarlette.middleware   sd     	g	
 	
 	

 &(((*[(((	 	 	 	 	 	 r=   )FNNNNNN)r$   r   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r.   r0   r1   r2   r3   )r2   r   )r2   rL   )rO   rP   rQ   r   r2   r   )rT   r   rU   r   rV   r   r2   r3   )rY   rP   r2   r   rN   )r\   rP   rG   r   rO   r]   r2   r3   )ra   rP   rG   r   rO   r]   r2   r3   )rc   rd   rI   re   rJ   rf   r2   r3   )rk   rl   r?   r   r2   r3   )rY   rP   ro   r   r2   r3   )NNT)r\   rP   rr   rs   rt   ru   rO   r]   rv   r&   r2   r3   )r\   rP   rr   r{   rO   r]   r2   r3   )rk   rl   r2   r   )
r\   rP   rt   ru   rO   r]   rv   r&   r2   r   )r\   rP   rO   r]   r2   r   )r   rP   r2   r   )__name__
__module____qualname____doc__r<   rK   propertyr'   rS   rX   r[   r`   ra   rj   rn   rq   rz   r   r   rr   r   r)    r=   r;   r    r       s       ++ -126DH9=:>-1/5 /5 /5 /5 /5b   , " " " X"= = = =: : : :0 0 0 04 4 4 4 43 3 3 3 3V V V VD D D D8 8 8 8 %)"&l l l l l  	@ @ @ @ @     %)"&    @    (     r=   ).
__future__r   sysr   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   r=   r;   <module>r      s   " " " " " " 



  8 8 8 8 8 8 8 8 8 8 ) ) ) ) ) ) ) ) ) )w       ++++++ 3 3 3 3 3 3 3 3 ? ? ? ? ? ? ? ? 8 8 8 8 8 8 = = = = = = ? ? ? ? ? ? & & & & & & ( ( ( ( ( ( / / / / / / / / U U U U U U U U U U U U U U U U * * * * * *
');
/
/
/IcNN^ ^ ^ ^ ^ ^ ^ ^ ^ ^r=   