
    ,h)                    D   d dl mZ d dlZd dlZd dl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jH                  dd      Z% ed      Z& G d d      Z'y)    )annotationsN)   
   )	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           X/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/starlette/applications.py__init__zStarlette.__init__   sx    L J$6;;N 	
L	
 
W
V
^fg(:(B"M_H`%/%7rT*=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)r*   r"   error_handlerr&   keyvaluer,   appclsargskwargss              r-   build_middleware_stackz Starlette.build_middleware_stackO   s    

`b11779 	0JCsI&& %*/"3'		0 -}ERS""#-8JRWXYZ 	 kk!)*!5 	,Cvc+D+F+C	,
r/   c                .    | j                   j                  S N)r$   r+   )r*   s    r-   r+   zStarlette.routese   s    {{!!!r/   c               <     | j                   j                  |fi |S r?   )r$   url_path_for)r*   namepath_paramss      r-   rA   zStarlette.url_path_fori   s    't{{''<<<r/   c                   K   | |d<   | j                   | j                         | _         | j                  |||       d {    y 7 w)Nr9   )r)   r=   )r*   scopereceivesends       r-   __call__zStarlette.__call__l   sD     e  ($($?$?$AD!##E7D999s   =AA Ac                8    | j                   j                  |      S r?   )r$   on_event)r*   
event_types     r-   rJ   zStarlette.on_eventr   s    {{##J//r/   c                @    | j                   j                  |||       y N)r9   rB   )r$   mount)r*   pathr9   rB   s       r-   rN   zStarlette.mountu   s    $Cd3r/   c                @    | j                   j                  |||       y rM   )r$   host)r*   rQ   r9   rB   s       r-   rQ   zStarlette.hostx   s    3T2r/   c                    | j                   t        d      | j                  j                  dt	        |g|i |       y )Nz6Cannot add middleware after an application has startedr   )r)   RuntimeErrorr(   insertr	   )r*   middleware_classr;   r<   s       r-   add_middlewarezStarlette.add_middleware{   sB       ,WXX##Az2B'TT'TV'TUr/   c                "    || j                   |<   y r?   )r&   )r*   exc_class_or_status_coder1   s      r-   add_exception_handlerzStarlette.add_exception_handler   s    
 =D 89r/   c                <    | j                   j                  ||       y r?   )r$   add_event_handler)r*   rK   funcs      r-   r[   zStarlette.add_event_handler   s    
 	%%j$7r/   c                D    | j                   j                  |||||       y N)methodsrB   include_in_schemar$   	add_route)r*   rO   router_   rB   r`   s         r-   rb   zStarlette.add_route   s"     	dE7Yjkr/   c                @    | j                   j                  |||       y N)rB   r$   add_websocket_route)r*   rO   rc   rB   s       r-   rg   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.c                ,    j                  |        | S r?   )rY   )r\   rX   r*   s    r-   	decoratorz.Starlette.exception_handler.<locals>.decorator   s    &&'?FKr/   r\   typing.Callablereturnrl   warningswarnDeprecationWarning)r*   rX   rj   s   `` r-   exception_handlerzStarlette.exception_handler   s%    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.c                H    j                   j                  |        | S r^   ra   )r\   r`   r_   rB   rO   r*   s    r-   rj   z"Starlette.route.<locals>.decorator   s0    KK!!"3 "  Kr/   rk   rn   )r*   rO   r_   rB   r`   rj   s   ````` r-   rc   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.c                D    j                   j                  |        | S re   rf   )r\   rB   rO   r*   s    r-   rj   z,Starlette.websocket_route.<locals>.decorator   s!    KK++D$T+BKr/   rk   rn   )r*   rO   rB   rj   s   ``` r-   websocket_routezStarlette.websocket_route   s'     	i	
	 r/   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)
        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.c                6    j                  t        |        | S )N)dispatch)rV   r   )r\   r*   s    r-   rj   z'Starlette.middleware.<locals>.decorator   s     2TBKr/   rk   rn   )r*   middleware_typerj   s   `  r-   r,   zStarlette.middleware   s:     	g	

 &([*[[	 r/   )FNNNNNN)r*   r   r"   boolr+   z!typing.Sequence[BaseRoute] | Noner,   z"typing.Sequence[Middleware] | Noner&   z3typing.Mapping[typing.Any, ExceptionHandler] | Noner   7typing.Sequence[typing.Callable[[], typing.Any]] | Noner    r~   r!   zLifespan[AppType] | Nonerm   None)rm   r   )rm   zlist[BaseRoute])rB   strrC   z
typing.Anyrm   r   )rE   r   rF   r   rG   r   rm   r   )rK   r   rm   rl   r?   )rO   r   r9   r   rB   
str | Nonerm   r   )rQ   r   r9   r   rB   r   rm   r   )rU   z_MiddlewareFactory[P]r;   zP.argsr<   zP.kwargsrm   r   )rX   int | type[Exception]r1   r   rm   r   )rK   r   r\   rl   rm   r   )NNT)rO   r   rc   zAtyping.Callable[[Request], typing.Awaitable[Response] | Response]r_   list[str] | NonerB   r   r`   r}   rm   r   )rO   r   rc   z4typing.Callable[[WebSocket], typing.Awaitable[None]]rB   r   rm   r   )rX   r   rm   rl   )
rO   r   r_   r   rB   r   r`   r}   rm   rl   )rO   r   rB   r   rm   rl   )r|   r   rm   rl   )__name__
__module____qualname____doc__r.   r=   propertyr+   rA   rH   rJ   rN   rQ   rV   rY   r[   rb   rg   rr   rc   rw   r,    r/   r-   r   r      s   + 489=RVNROS-1/5/5/5 2/5 7	/5
 P/5 L/5 M/5 +/5 
/5b, " "=:043V/V V 	V
 
VD"7D "D 
	D88 8 
	8 %)"&ll Ql "	l
 l  l 
l  	@@ D@ 	@
 
@  %)"& " 	
   
@(r/   )(
__future__r   systypingro   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   TypeVarr   r   r   r   r/   r-   <module>r      sm    " 
  w + 3 ? 8 = ? & ( / U U *
&..+
6cN^ ^r/   