
    g)                    @   S SK Jr  S SKrS SKrS SKr\R
                  S:  a  S SKJr  OS SKJr  S SKJ	r	J
r
  S SKJrJr  S SKJr  S SKJr  S S	KJr  S S
KJr  S SKJr  S SKJrJr  S SKJrJrJrJrJ r J!r!  S SK"J#r#  \RH                  " SSS9r%\" S5      r& " S S5      r'g)    )annotationsN)   
   )	ParamSpec)StateURLPath)
Middleware_MiddlewareFactory)BaseHTTPMiddleware)ServerErrorMiddleware)ExceptionMiddleware)Request)Response)	BaseRouteRouter)ASGIAppExceptionHandlerLifespanReceiveScopeSend)	WebSocketAppType	Starlette)boundPc                     \ rS rSrSr       S                 SS jjrSS jr\SS j5       rSS jr	SS jr
SS	 jrSSS
 jjrSSS jjr        S S jr      S!S jr      S"S jr   S#           S$S jjr S       S%S jjrS&S jr   S#         S'S jjrSS(S jjrS)S jrSrg)*r      z!Creates an Starlette application.Nc                    Ub  Uc  Ub   S5       eXl         [        5       U l        [        X%XgS9U l        Uc  0 O
[        U5      U l        Uc  / O
[        U5      U l        SU l	        g)a8  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           O/home/matz/Project1/venv/lib/python3.13/site-packages/starlette/applications.py__init__Starlette.__init__   sy    L ;#6	LK	L 
 
W
Vg(:(B"M_H`%/%7rT*=M04    c                F   U R                   nS n0 nU R                  R                  5        H  u  pEUS[        4;   a  UnM  XSU'   M     [	        [
        X!S9/U R                  -   [	        [        X1S9/-   nU R                  n[        U5       H  u  pn
U" U/U	Q70 U
D6nM     U$ )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_stack Starlette.build_middleware_stackO   s    

`b11779JCsI&& %*/3'	 : -}RS""#-8JXYZ 	 kk!)*!5Cvc+D+F+C "6
r1   c                .    U R                   R                  $ N)r%   r,   )r+   s    r.   r,   Starlette.routese   s    {{!!!r1   c               <    U R                   R                  " U40 UD6$ rB   )r%   url_path_for)r+   namepath_paramss      r.   rE   Starlette.url_path_fori   s    {{''<<<r1   c                   #    XS'   U R                   c  U R                  5       U l         U R                  XU5      I S h  vN   g  N7f)Nr;   )r*   r?   )r+   scopereceivesends       r.   __call__Starlette.__call__l   s?     e  ($($?$?$AD!##ED999s   <AAAc                8    U R                   R                  U5      $ rB   )r%   on_event)r+   
event_types     r.   rP   Starlette.on_eventr   s    {{##J//r1   c                8    U R                   R                  XUS9  g N)r;   rF   )r%   mount)r+   pathr;   rF   s       r.   rU   Starlette.mountu   s    $d3r1   c                8    U R                   R                  XUS9  g rT   )r%   host)r+   rY   r;   rF   s       r.   rY   Starlette.hostx   s    T2r1   c                    U R                   b  [        S5      eU R                  R                  S[	        U/UQ70 UD65        g )Nz6Cannot add middleware after an application has startedr   )r*   RuntimeErrorr)   insertr	   )r+   middleware_classr=   r>   s       r.   add_middlewareStarlette.add_middleware{   sB       ,WXX##Az2B'TT'TV'TUr1   c                     X R                   U'   g rB   )r'   )r+   exc_class_or_status_coder3   s      r.   add_exception_handlerStarlette.add_exception_handler   s    
 =D 89r1   c                :    U R                   R                  X5        g rB   )r%   add_event_handler)r+   rQ   funcs      r.   rf   Starlette.add_event_handler   s    
 	%%j7r1   c                :    U R                   R                  XX4US9  g N)methodsrF   include_in_schemar%   	add_route)r+   rV   routerk   rF   rl   s         r.   rn   Starlette.add_route   s     	d7Yjkr1   c                8    U R                   R                  XUS9  g N)rF   r%   add_websocket_route)r+   rV   ro   rF   s       r.   rt   Starlette.add_websocket_route   s     	''$'?r1   c                R   ^ ^ [         R                  " S[        5        SUU 4S jjnU$ )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                ,   > TR                  TU 5        U $ rB   )rc   )rg   rb   r+   s    r.   	decorator.Starlette.exception_handler.<locals>.decorator   s    &&'?FKr1   rg   typing.Callablereturnr{   warningswarnDeprecationWarning)r+   rb   rx   s   `` r.   exception_handlerStarlette.exception_handler   s*    Z	
	 	 r1   c                ^   ^ ^^^^ [         R                  " S[        5        SUUUUU 4S jjnU$ )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                B   > TR                   R                  TU TTTS9  U $ rj   rm   )rg   rl   rk   rF   rV   r+   s    r.   rx   "Starlette.route.<locals>.decorator   s0    KK!!"3 "  Kr1   rz   r}   )r+   rV   rk   rF   rl   rx   s   ````` r.   ro   Starlette.route   s,     	W	
	 	 r1   c                V   ^ ^^ [         R                  " S[        5        SUUU 4S jjnU$ )z
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                >   > TR                   R                  TU TS9  U $ rr   rs   )rg   rF   rV   r+   s    r.   rx   ,Starlette.websocket_route.<locals>.decorator   s!    KK++D$T+BKr1   rz   r}   )r+   rV   rF   rx   s   ``` r.   websocket_routeStarlette.websocket_route   s,     	i	
	 	 r1   c                h   ^  [         R                  " S[        5        US:X  d   S5       eSU 4S jjnU$ )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                0   > TR                  [        U S9  U $ )N)dispatch)r_   r   )rg   r+   s    r.   rx   'Starlette.middleware.<locals>.decorator   s     2TBKr1   rz   r}   )r+   middleware_typerx   s   `  r.   r-   Starlette.middleware   s=     	g	

 &([*[[(	 r1   )r#   r'   r*   r%   r$   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] | Noner|   None)r|   r   )r|   zlist[BaseRoute])rF   strrG   z
typing.Anyr|   r   )rJ   r   rK   r   rL   r   r|   r   )rQ   r   r|   r{   rB   )rV   r   r;   r   rF   
str | Noner|   r   )rY   r   r;   r   rF   r   r|   r   )r^   z_MiddlewareFactory[P]r=   zP.argsr>   zP.kwargsr|   r   )rb   int | type[Exception]r3   r   r|   r   )rQ   r   rg   r{   r|   r   )NNT)rV   r   ro   zAtyping.Callable[[Request], typing.Awaitable[Response] | Response]rk   list[str] | NonerF   r   rl   r   r|   r   )rV   r   ro   z4typing.Callable[[WebSocket], typing.Awaitable[None]]rF   r   r|   r   )rb   r   r|   r{   )
rV   r   rk   r   rF   r   rl   r   r|   r{   )rV   r   rF   r   r|   r{   )r   r   r|   r{   )__name__
__module____qualname____firstlineno____doc__r/   r?   propertyr,   rE   rM   rP   rU   rY   r_   rc   rf   rn   rt   r   ro   r   r-   __static_attributes__ r1   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@ 	@
 
@  %)"& " 	
   
@(r1   )(
__future__r   systypingr~   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   r1   r.   <module>r      sk    " 
  w + 3 ? 8 = ? & ( / U U *
..+
6cN^ ^r1   