Skip to main content
Glama

API Docs MCP Server

applications.cpython-310.pyc10.6 kB
o �I�g�)�@sddlmZddlZddlZddlZejdkrddlmZnddlmZddlm Z m Z ddl m Z m Z ddlmZddlmZdd lmZdd lmZdd lmZdd 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�Z dddfd6d7�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�dC:\Users\apqls\Documents\Github\tkbase\api-docs-mcp\venv\Lib\site-packages\starlette/applications.py�__init__s&� zStarlette.__init__rc Cs�|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� Exceptionrr r0r r-�reversed) rrZ 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|��SrB)r-� url_path_for)rrDrFr2r2r3rHiszStarlette.url_path_for�scoper�receiver�sendrc�s6�||d<|jdur|��|_|�|||�IdHdS)Nr<)r1r@)rrIrJrKr2r2r3�__call__ls �  zStarlette.__call__� event_type�typing.CallablecCs |j�|�SrB)r-�on_event)rrMr2r2r3rOrs zStarlette.on_event�pathr<� str | NonecC�|jj|||d�dS�N)r<rD)r-�mount)rrPr<rDr2r2r3rTu�zStarlette.mount�hostcCrRrS)r-rV)rrVr<rDr2r2r3rVxrUzStarlette.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)rrWr>r?r2r2r3�add_middleware{s $zStarlette.add_middleware�exc_class_or_status_code�int | type[Exception]r5rcCs||j|<dSrB)r#)rr^r5r2r2r3�add_exception_handler�szStarlette.add_exception_handler�funccCs|j�||�dSrB)r-�add_event_handler)rrMrar2r2r3rb�szStarlette.add_event_handlerT�route�Atyping.Callable[[Request], typing.Awaitable[Response] | Response]�methods�list[str] | None�include_in_schemacCs|jj|||||d�dS�N)rerDrg�r-� add_route)rrPrcrerDrgr2r2r3rj�szStarlette.add_route�4typing.Callable[[WebSocket], typing.Awaitable[None]]cCrR�N)rD�r-�add_websocket_route)rrPrcrDr2r2r3rn�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.rarNr*cs���|�|SrB)r`�ra�r^rr2r3� decorator�s z.Starlette.exception_handler.<locals>.decorator�rarNr*rN��warnings�warn�DeprecationWarning)rr^rqr2rpr3�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.rarNr*cs�jj�|���d�|Srhriro�rgrerDrPrr2r3rq�s�z"Starlette.route.<locals>.decoratorNrrrs)rrPrerDrgrqr2rxr3rc�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.rarNr*cs�jj�|�d�|Srlrmro�rDrPrr2r3rq�sz,Starlette.websocket_route.<locals>.decoratorNrrrs)rrPrDrqr2ryr3�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.rarNr*cs�jt|d�|S)N)�dispatch)r]r rorCr2r3rq�sz'Starlette.middleware.<locals>.decoratorNrrrs)rr{rqr2rCr3r!�s�zStarlette.middleware)FNNNNNN)rrrrrr r!r"r#r$r%r&r'r&r(r)r*r+)r*r)r*rA)rDrErFrGr*r)rIrrJrrKrr*r+)rMrEr*rNrB)rPrEr<rrDrQr*r+)rVrEr<rrDrQr*r+)rWrXr>rYr?rZr*r+)r^r_r5rr*r+)rMrErarNr*r+)NNT) rPrErcrdrerfrDrQrgrr*r+)rPrErcrkrDrQr*r+)r^r_r*rN) rPrErerfrDrQrgrr*rN)rPrErDrQr*rN)r{rEr*rN)�__name__� __module__� __qualname__�__doc__r4r@�propertyrrHrLrOrTrVr]r`rbrjrnrwrcrzr!r2r2r2r3rsD � 1          � �  � )(� __future__r�sys�typingrt� version_inforZtyping_extensionsZstarlette.datastructuresrrZstarlette.middlewarerr Zstarlette.middleware.baser Zstarlette.middleware.errorsr Zstarlette.middleware.exceptionsr Zstarlette.requestsr Zstarlette.responsesrZstarlette.routingrrZstarlette.typesrrrrrrZstarlette.websocketsr�TypeVarrrrr2r2r2r3�<module>s(          

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ShotaNagafuchi/api-docs-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server