xjddlmZddlmZmZmZmZddlmZm Z m Z ddl m Z m Z ddlmZmZddlmZddlmZddlmZdd lmZdd lmZdd lmZmZdd lmZm Z m!Z!m"Z"m#Z#m$Z$e d dZ%e dZ&GddZ'y)) annotations) AwaitableCallableMappingSequence)Any ParamSpecTypeVar)StateURLPath) Middleware_MiddlewareFactory)RequestBodyLimitMiddleware)ServerErrorMiddleware)ExceptionMiddleware)Request)Response) BaseRouteRouter)ASGIAppExceptionHandlerLifespanReceiveScopeSendAppType Starlette)boundPceZdZdZ ddd ddZddZeddZddZddZ ddd Z ddd Z dd Z dd Z d dd Zy)rz!Creates an Starlette application.N max_body_sizec||_t|_t|||_||_|in t ||_|gn t||_ d|_ y)aInitializes 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. max_body_size: Non-negative maximum total size in bytes of an HTTP request body. The default, `None`, does not limit request body size. )lifespanN) debugr staterrouterr"dictexception_handlerslistuser_middlewaremiddleware_stack)selfr%routes middlewarer)r$r"s j/mnt/ssd/data/Dropbox/adrian/sandbox/mcp-query/venv/lib/python3.12/site-packages/starlette/applications.py__init__zStarlette.__init__s\@ W Vh7 *(:(B"M_H`%/%7rT*=M04c|j}d}i}|jjD]\}}|dtfvr|}|||<t t ||g}|j *|jt t|j ||jz }|jt t|||j}t|D]\}} } ||g| i| }|S)Ni)handlerr%r!)handlersr%) r%r)items Exceptionr rr"appendrr+rr'reversed) r-r% error_handlerr)keyvaluer/appclsargskwargss r0build_middleware_stackz Starlette.build_middleware_stack?s  :<11779 0JCsI&& % */"3'  0 !!6 UZ[\    )   j)CSWSeSef gd*** *%8CU]bcdkk!)*!5 , Cvc+D+F+C , r2c.|jjSN)r'r.)r-s r0r.zStarlette.routesUs{{!!!r2c <|jj|fi|SrC)r' url_path_for)r-name path_paramss r0rEzStarlette.url_path_forYs't{{''< <rwsU"BB**3?F=?&(/UU ); / cNhlhlr2