
    h?1i)                        d dl mZ d dlZd dl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 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j>                  dd      Z  G d d      Z!y)    )annotationsN)StateURLPath)
Middleware)BaseHTTPMiddleware)ServerErrorMiddleware)ExceptionMiddleware)Request)Response)	BaseRouteRouter)ASGIAppExceptionHandlerLifespanReceiveScopeSend)	WebSocketAppType	Starlette)boundc                  P   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   aI  
    Creates an application instance.

    **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 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 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.
    Nc                    |||J d       || _         t               | _        t        ||||      | _        |i n
t        |      | _        |g n
t        |      | _        d | _	        y )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           `/home/www/therecruiter.miabetepe.com/venv/lib/python3.12/site-packages/starlette/applications.py__init__zStarlette.__init__2   s     ;#6	LK	L 
 
W
z{X
 %,B$7I2J 	 &0%7rT*=M:>    c                H   | j                   }d }i }| j                  j                         D ]  \  }}|dt        fv r|}|||<    t	        t
        ||      g| j                  z   t	        t        ||      gz   }| j                  }t        |      D ]  \  }}	 |dd|i|	} |S )Ni  )handlerr   )handlersr   app )
r   r!   items	Exceptionr   r   r#   r	   r   reversed)
r%   r   error_handlerr!   keyvaluer'   r.   clsoptionss
             r(   build_middleware_stackz Starlette.build_middleware_stackM   s    

  	 11779 	0JCsI&& %*/"3'		0 -}ERS""# '2DE 	 kk$Z0 	*LC)#))C	*
r*   c                .    | j                   j                  S N)r   r&   )r%   s    r(   r&   zStarlette.routesi   s    {{!!!r*   c               <     | j                   j                  |fi |S r:   )r   url_path_for)r%   namepath_paramss      r(   r<   zStarlette.url_path_form   s    't{{''<<<r*   c                   K   | |d<   | j                   | j                         | _         | j                  |||       d {    y 7 w)Nr.   )r$   r8   )r%   scopereceivesends       r(   __call__zStarlette.__call__p   sD     e  ($($?$?$AD!##E7D999s   =AA Ac                8    | j                   j                  |      S r:   )r   on_event)r%   
event_types     r(   rE   zStarlette.on_eventv   s    {{##J//r*   c                @    | j                   j                  |||       y N)r.   r=   )r   mount)r%   pathr.   r=   s       r(   rI   zStarlette.mounty   s    $Cd3r*   c                @    | j                   j                  |||       y rH   )r   host)r%   rL   r.   r=   s       r(   rL   zStarlette.host|   s    3T2r*   c                ~    | j                   t        d      | j                  j                  dt	        |fi |       y )Nz6Cannot add middleware after an application has startedr   )r$   RuntimeErrorr#   insertr   )r%   middleware_classr7   s      r(   add_middlewarezStarlette.add_middleware   s;      ,WXX##Az2B'Ng'NOr*   c                "    || j                   |<   y r:   )r!   )r%   exc_class_or_status_coder,   s      r(   add_exception_handlerzStarlette.add_exception_handler   s    
 =D 89r*   c                <    | j                   j                  ||       y r:   )r   add_event_handler)r%   rF   funcs      r(   rV   zStarlette.add_event_handler   s     	%%j$7r*   c                D    | j                   j                  |||||       y N)methodsr=   include_in_schemar   	add_route)r%   rJ   routerZ   r=   r[   s         r(   r]   zStarlette.add_route   s'     	%tGX 	 	
r*   c                @    | j                   j                  |||       y N)r=   r   add_websocket_route)r%   rJ   r^   r=   s       r(   rb   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:   )rT   )rW   rS   r%   s    r(   	decoratorz.Starlette.exception_handler.<locals>.decorator   s    &&'?FKr*   rW   typing.Callablereturnrg   warningswarnDeprecationWarning)r%   rS   re   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 rY   r\   )rW   r[   rZ   r=   rJ   r%   s    r(   re   z"Starlette.route.<locals>.decorator   s0    KK!!"3 "  Kr*   rf   ri   )r%   rJ   rZ   r=   r[   re   s   ````` r(   r^   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 r`   ra   )rW   r=   rJ   r%   s    r(   re   z,Starlette.websocket_route.<locals>.decorator   s!    KK++D$T+BKr*   rf   ri   )r%   rJ   r=   re   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)rQ   r   )rW   r%   s    r(   re   z'Starlette.middleware.<locals>.decorator   s     2TBKr*   rf   ri   )r%   middleware_typere   s   `  r(   r'   zStarlette.middleware   sA     	g	
 v%	=<	=%	 r*   )FNNNNNN)r%   z	'AppType'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   ry   r   z$typing.Optional[Lifespan['AppType']]rh   None)rh   r   )rh   ztyping.List[BaseRoute])r=   strr>   
typing.Anyrh   r   )r@   r   rA   r   rB   r   rh   rz   )rF   r{   rh   rg   r:   )rJ   r{   r.   r   r=   
str | Nonerh   rz   )rL   r{   r.   r   r=   r}   rh   rz   )rP   typer7   r|   rh   rz   )rS   int | typing.Type[Exception]r,   r   rh   rz   )rF   r{   rW   rg   rh   rz   )NNT)rJ   r{   r^   zAtyping.Callable[[Request], typing.Awaitable[Response] | Response]rZ   z!typing.Optional[typing.List[str]]r=   ztyping.Optional[str]r[   rx   rh   rz   )rJ   r{   r^   z4typing.Callable[[WebSocket], typing.Awaitable[None]]r=   r}   rh   rz   )rS   r   rh   rg   )
rJ   r{   rZ   ztyping.List[str] | Noner=   r}   r[   rx   rh   rg   )rJ   r{   r=   r}   rh   rg   )rw   r{   rh   rg   )__name__
__module____qualname____doc__r)   r8   propertyr&   r<   rC   rE   rI   rL   rQ   rT   rV   r]   rb   rm   r^   rr   r'   r/   r*   r(   r   r      s   > 489=RVNROS9=??? 2? 7	?
 P? L? M? 7? 
?68 " "=:043P
D">D "D 
	D88%48	8 6:%)"&



 Q

 3	


 #

  

 


   	@@ D@ 	@
 
@(D	$ ,0"& ) 	
   
B -1)	,r*   )"
__future__r   typingrj   starlette.datastructuresr   r   starlette.middlewarer   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(   <module>r      sM    "   3 + 8 = ? & ( / U U *
&..+
6j jr*   