HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib/python3.10/site-packages/starlette/__pycache__/applications.cpython-310.pyc
o

�h�)�@sddlmZddlZddlZddlZejdkrddlmZnddlmZddlm	Z	m
Z
ddlmZm
Z
ddlmZddlmZdd	lmZdd
lmZddlmZddlmZmZdd
lmZmZmZmZm Z m!Z!ddl"m#Z#ej$ddd�Z%ed�Z&Gdd�d�Z'dS)�)�annotationsN)��
)�	ParamSpec)�State�URLPath)�
Middleware�_MiddlewareFactory)�BaseHTTPMiddleware)�ServerErrorMiddleware)�ExceptionMiddleware)�Request)�Response)�	BaseRoute�Router)�ASGIApp�ExceptionHandler�Lifespan�Receive�Scope�Send)�	WebSocket�AppType�	Starlette)�bound�Pc@s�eZdZdZ							d]d^dd�Zd_dd�Zed`dd��Zdad"d#�Zdbd*d+�Z	dcd.d/�Z
ddded3d4�Zdddfd6d7�Zdgd>d?�Z
dhdDdE�ZdidGdH�Z			IdjdkdOdP�Z	dddldRdS�ZdmdTdU�Z			IdjdndVdW�ZdddodXdY�Zdpd[d\�ZdS)qrz!Creates an Starlette application.FN�selfr�debug�bool�routes�!typing.Sequence[BaseRoute] | None�
middleware�"typing.Sequence[Middleware] | None�exception_handlers�3typing.Mapping[typing.Any, ExceptionHandler] | None�
on_startup�7typing.Sequence[typing.Callable[[], typing.Any]] | None�on_shutdown�lifespan�Lifespan[AppType] | None�return�NonecCsv|dus|dur|dusJd��||_t�|_t||||d�|_|dur&int|�|_|dur1gnt|�|_d|_	dS)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'r()
rr�stater�router�dictr#�list�user_middleware�middleware_stack)rrrr!r#r%r'r(�r2�I/usr/local/CyberCP/lib/python3.10/site-packages/starlette/applications.py�__init__s&�
zStarlette.__init__rcCs�|j}d}i}|j��D]\}}|dtfvr|}q|||<qtt||d�g|jtt||d�g}|j}t	|�D]\}}	}
||g|	�Ri|
��}q8|S)Ni�)�handlerr)�handlersr)
rr#�items�	Exceptionrrr0rr-�reversed)rr�
error_handlerr#�key�valuer!�app�cls�args�kwargsr2r2r3�build_middleware_stackOs"
���z Starlette.build_middleware_stack�list[BaseRoute]cCs|jjS�N)r-r�rr2r2r3reszStarlette.routes�name�str�path_params�
typing.AnyrcKs|jj|fi|��SrC)r-�url_path_for)rrErGr2r2r3rIiszStarlette.url_path_for�scoper�receiver�sendrc�s6�||d<|jdur|��|_|�|||�IdHdS)Nr=)r1rA)rrJrKrLr2r2r3�__call__ls
�

zStarlette.__call__�
event_type�typing.CallablecCs|j�|�SrC)r-�on_event)rrNr2r2r3rPrszStarlette.on_event�pathr=�
str | NonecC�|jj|||d�dS�N)r=rE)r-�mount)rrQr=rEr2r2r3rUu�zStarlette.mount�hostcCrSrT)r-rW)rrWr=rEr2r2r3rWxrVzStarlette.host�middleware_class�_MiddlewareFactory[P]r?�P.argsr@�P.kwargscOs6|jdur	td��|j�dt|g|�Ri|���dS)Nz6Cannot add middleware after an application has startedr)r1�RuntimeErrorr0�insertr)rrXr?r@r2r2r3�add_middleware{s
$zStarlette.add_middleware�exc_class_or_status_code�int | type[Exception]r5rcCs||j|<dSrC)r#)rr_r5r2r2r3�add_exception_handler�szStarlette.add_exception_handler�funccCs|j�||�dSrC)r-�add_event_handler)rrNrbr2r2r3rc�szStarlette.add_event_handlerT�route�Atyping.Callable[[Request], typing.Awaitable[Response] | Response]�methods�list[str] | None�include_in_schemacCs|jj|||||d�dS�N)rfrErh�r-�	add_route)rrQrdrfrErhr2r2r3rk�szStarlette.add_route�4typing.Callable[[WebSocket], typing.Awaitable[None]]cCrS�N)rE�r-�add_websocket_route)rrQrdrEr2r2r3ro�szStarlette.add_websocket_routecs t�dt�d��fdd�}|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.rbrOr*cs���|�|SrC)ra�rb�r_rr2r3�	decorator�sz.Starlette.exception_handler.<locals>.decorator�rbrOr*rO��warnings�warn�DeprecationWarning)rr_rrr2rqr3�exception_handler�s�zStarlette.exception_handlercs&t�dt�d�����fdd�}|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.rbrOr*cs�jj�|���d�|Srirjrp�rhrfrErQrr2r3rr�s�z"Starlette.route.<locals>.decoratorNrsrt)rrQrfrErhrrr2ryr3rd�s�
zStarlette.routecs"t�dt�d���fdd�}|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.rbrOr*cs�jj�|�d�|Srmrnrp�rErQrr2r3rr�sz,Starlette.websocket_route.<locals>.decoratorNrsrt)rrQrErrr2rzr3�websocket_route�s�zStarlette.websocket_route�middleware_typecs.t�dt�|dksJd��d
�fdd�}|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.rbrOr*cs�jt|d�|S)N)�dispatch)r^r
rprDr2r3rr�sz'Starlette.middleware.<locals>.decoratorNrsrt)rr|rrr2rDr3r!�s�zStarlette.middleware)FNNNNNN)rrrrrr r!r"r#r$r%r&r'r&r(r)r*r+)r*r)r*rB)rErFrGrHr*r)rJrrKrrLrr*r+)rNrFr*rOrC)rQrFr=rrErRr*r+)rWrFr=rrErRr*r+)rXrYr?rZr@r[r*r+)r_r`r5rr*r+)rNrFrbrOr*r+)NNT)rQrFrdrerfrgrErRrhrr*r+)rQrFrdrlrErRr*r+)r_r`r*rO)
rQrFrfrgrErRrhrr*rO)rQrFrErRr*rO)r|rFr*rO)�__name__�
__module__�__qualname__�__doc__r4rA�propertyrrIrMrPrUrWr^rarcrkrorxrdr{r!r2r2r2r3rsD�
1






��
� )(�
__future__r�sys�typingru�version_infor�typing_extensions�starlette.datastructuresrr�starlette.middlewarerr	�starlette.middleware.baser
�starlette.middleware.errorsr�starlette.middleware.exceptionsr�starlette.requestsr
�starlette.responsesr�starlette.routingrr�starlette.typesrrrrrr�starlette.websocketsr�TypeVarrrrr2r2r2r3�<module>s(