File: //usr/local/CyberCP/lib/python3.10/site-packages/starlette/__pycache__/applications.cpython-310.pyc
o
�h�) � @ s d dl mZ d dlZd dlZd dlZejdkrd dlmZ nd dlmZ d dlm Z m
Z
d dlmZm
Z
d dlmZ d dlmZ d d lmZ d d
lmZ d dlmZ d dlmZmZ d d
lmZmZmZmZm Z m!Z! d dl"m#Z# ej$ddd�Z%ed�Z&G dd� 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� e Zd ZdZ d]d^dd�Zd_dd�Zed`dd��Zdad"d#�Zdbd*d+�Z dcd.d/�Z
ddded3d4�Zdddfd6d7�Zdgd>d?�Z
dhdDdE�ZdidGdH�Z IdjdkdOdP�Z dddldRdS�ZdmdTdU�Z IdjdndVdW�ZdddodXdY�Zdpd[d\�ZdS )qr z!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�Nonec C sv |du s|du r|du sJ d��|| _ t� | _t||||d�| _|du r&i nt|�| _|du r1g nt|�| _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'