网页 综合 更新时间 2026-11-14 09:44:40

Applications - Starlette

自动蜘蛛 starlette.dev 正文约 1446 字
Creates a Starlette application.
Boolean indicating if debug tracebacks should be returned on errors.
A list of routes to serve incoming HTTP and WebSocket requests.
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.
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.
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.
Non-negative maximum total size in bytes of an HTTP request body. The default, None, does not limit request body size.
Starlette includes an application class Starlette that nicely ties together all of its other functionality.
You can store arbitrary extra state on the application instance, using the generic app.state attribute.
Where a request is available (i.e. endpoints and middleware), the app is available on request.app.
访问原文 返回搜索 https://starlette.dev/websockets/../applications/
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。