网页
综合
更新时间 2026-11-14 05:21:10
Index - Uvicorn
自动蜘蛛
uvicorn.dev
正文约 2312 字
An ASGI web server, for Python.
Documentation: https://uvicorn.dev
Source Code: https://www.github.com/Kludex/uvicorn
Uvicorn is an ASGI web server implementation for Python.
Until recently Python has lacked a minimal low-level server/application interface for async frameworks. The ASGI specification fills this gap, and means we're now able to start building a common set of tooling usable across all async frameworks.
Uvicorn currently supports HTTP/1.1, HTTP/2 and WebSockets.
Help us keep Uvicorn maintained and sustainable by becoming a sponsor.
Uvicorn is available on PyPI so installation is as simple as:
See the installation documentation for more information.
Let's create a simple ASGI application to run with Uvicorn:
Then we can run it with Uvicorn:
The uvicorn command line tool is the easiest way to run your application.
Run uvicorn --help to see the full set of command line options.
For more information, see the settings documentation.
There are several ways to run uvicorn directly from your application.
If you're looking for a programmatic equivalent of the uvicorn command line interface, use uvicorn.run():
For more control over configuration and server lifecycle, use uvicorn.Config and uvicorn.Server:
If you'd like to run Uvicorn from an already running async environment, use uvicorn.Server.serve() instead:
The uvicorn.workers module is deprecated and will be removed in a future release.
You should use the uvicorn-worker package instead.
Gunicorn is a mature, fully featured server and process manager.
Uvicorn includes a Gunicorn worker class allowing you to run ASGI applications, with all of Uvicorn's performance benefits, while also giving you Gunicorn's fully-featured process management.
This allows you to increase or decrease the number of worker processes on the fly, restart worker processes gracefully, or perform server upgrades without downtime.
For production deployments we recommend using gunicorn with the uvicorn worker class.
For a PyPy compatible configuration use uvicorn.workers.UvicornH11Worker.
For more information, see the deployment documentation.
The --factory flag allows loading the application from a factory function, rather than an application instance directly. The factory will be called with no arguments and should return an ASGI application.
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。