XjddlmZddlmZmZmZmZddlmZm Z m Z ddl m Z m Z ddlmZmZddlmZddlmZddlmZdd lmZdd lmZmZdd lmZmZmZm Z m!Z!m"Z"e d d Z#e dZ$Gdd Z%y)) annotations) AwaitableCallableMappingSequence)Any ParamSpecTypeVar)StateURLPath) Middleware_MiddlewareFactory)ServerErrorMiddleware)ExceptionMiddleware)Request)Response) BaseRouteRouter)ASGIAppExceptionHandlerLifespanReceiveScopeSendAppType Starlette)boundPceZdZdZ d ddZddZeddZddZddZ dddZ ddd Z dd Z dd Z d dd Zy)rz!Creates an Starlette application.Nc||_t|_t|||_|in t ||_|gn t||_d|_ y)aAInitializes 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. 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. )lifespanN) debugr staterrouterdictexception_handlerslistuser_middlewaremiddleware_stack)selfr"routes middlewarer&r!s j/mnt/ssd/data/Dropbox/adrian/vault-secondbrain/venv/lib/python3.12/site-packages/starlette/applications.py__init__zStarlette.__init__sS8 W Vh7 (:(B"M_H`%/%7rT*=M04cN|j}d}i}|jjD]\}}|dtfvr|}|||<t t ||g|j zt t||gz}|j}t|D]\}} } ||g| i| }|S)Ni)handlerr")handlersr") r"r&items Exceptionr rr(rr$reversed) r*r" error_handlerr&keyvaluer,appclsargskwargss r-build_middleware_stackz Starlette.build_middleware_stack9s  :<11779 0JCsI&& % */"3'  0-}E R S"" #-8JRWXY Z  kk!)*!5 , Cvc+D+F+C , r/c.|jjSN)r$r+)r*s r-r+zStarlette.routesOs{{!!!r/c <|jj|fi|Sr?)r$ url_path_for)r*name path_paramss r-rAzStarlette.url_path_forSs't{{''< <rrsR"BB**3?=?&(/UU ); / cNclclr/