METADATA 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. Metadata-Version: 2.4
  2. Name: uvicorn
  3. Version: 0.37.0
  4. Summary: The lightning-fast ASGI server.
  5. Project-URL: Changelog, https://uvicorn.dev/release-notes
  6. Project-URL: Funding, https://github.com/sponsors/encode
  7. Project-URL: Homepage, https://uvicorn.dev/
  8. Project-URL: Source, https://github.com/Kludex/uvicorn
  9. Author-email: Tom Christie <tom@tomchristie.com>, Marcelo Trylesinski <marcelotryle@gmail.com>
  10. License-Expression: BSD-3-Clause
  11. License-File: LICENSE.md
  12. Classifier: Development Status :: 4 - Beta
  13. Classifier: Environment :: Web Environment
  14. Classifier: Intended Audience :: Developers
  15. Classifier: License :: OSI Approved :: BSD License
  16. Classifier: Operating System :: OS Independent
  17. Classifier: Programming Language :: Python :: 3
  18. Classifier: Programming Language :: Python :: 3.9
  19. Classifier: Programming Language :: Python :: 3.10
  20. Classifier: Programming Language :: Python :: 3.11
  21. Classifier: Programming Language :: Python :: 3.12
  22. Classifier: Programming Language :: Python :: 3.13
  23. Classifier: Programming Language :: Python :: Implementation :: CPython
  24. Classifier: Programming Language :: Python :: Implementation :: PyPy
  25. Classifier: Topic :: Internet :: WWW/HTTP
  26. Requires-Python: >=3.9
  27. Requires-Dist: click>=7.0
  28. Requires-Dist: h11>=0.8
  29. Requires-Dist: typing-extensions>=4.0; python_version < '3.11'
  30. Provides-Extra: standard
  31. Requires-Dist: colorama>=0.4; (sys_platform == 'win32') and extra == 'standard'
  32. Requires-Dist: httptools>=0.6.3; extra == 'standard'
  33. Requires-Dist: python-dotenv>=0.13; extra == 'standard'
  34. Requires-Dist: pyyaml>=5.1; extra == 'standard'
  35. Requires-Dist: uvloop>=0.15.1; (sys_platform != 'win32' and (sys_platform != 'cygwin' and platform_python_implementation != 'PyPy')) and extra == 'standard'
  36. Requires-Dist: watchfiles>=0.13; extra == 'standard'
  37. Requires-Dist: websockets>=10.4; extra == 'standard'
  38. Description-Content-Type: text/markdown
  39. <p align="center">
  40. <img width="320" height="320" src="https://raw.githubusercontent.com/tomchristie/uvicorn/main/docs/uvicorn.png" alt='uvicorn'>
  41. </p>
  42. <p align="center">
  43. <em>An ASGI web server, for Python.</em>
  44. </p>
  45. ---
  46. [![Build Status](https://github.com/Kludex/uvicorn/workflows/Test%20Suite/badge.svg)](https://github.com/Kludex/uvicorn/actions)
  47. [![Package version](https://badge.fury.io/py/uvicorn.svg)](https://pypi.python.org/pypi/uvicorn)
  48. [![Supported Python Version](https://img.shields.io/pypi/pyversions/uvicorn.svg?color=%2334D058)](https://pypi.org/project/uvicorn)
  49. **Documentation**: [https://uvicorn.dev](https://uvicorn.dev)
  50. **Source Code**: [https://www.github.com/Kludex/uvicorn](https://www.github.com/Kludex/uvicorn)
  51. ---
  52. Uvicorn is an ASGI web server implementation for Python.
  53. Until recently Python has lacked a minimal low-level server/application interface for
  54. async frameworks. The [ASGI specification][asgi] fills this gap, and means we're now able to
  55. start building a common set of tooling usable across all async frameworks.
  56. Uvicorn supports HTTP/1.1 and WebSockets.
  57. ## Quickstart
  58. Install using `pip`:
  59. ```shell
  60. $ pip install uvicorn
  61. ```
  62. This will install uvicorn with minimal (pure Python) dependencies.
  63. ```shell
  64. $ pip install 'uvicorn[standard]'
  65. ```
  66. This will install uvicorn with "Cython-based" dependencies (where possible) and other "optional extras".
  67. In this context, "Cython-based" means the following:
  68. - the event loop `uvloop` will be installed and used if possible.
  69. - the http protocol will be handled by `httptools` if possible.
  70. Moreover, "optional extras" means that:
  71. - the websocket protocol will be handled by `websockets` (should you want to use `wsproto` you'd need to install it manually) if possible.
  72. - the `--reload` flag in development mode will use `watchfiles`.
  73. - windows users will have `colorama` installed for the colored logs.
  74. - `python-dotenv` will be installed should you want to use the `--env-file` option.
  75. - `PyYAML` will be installed to allow you to provide a `.yaml` file to `--log-config`, if desired.
  76. Create an application, in `example.py`:
  77. ```python
  78. async def app(scope, receive, send):
  79. assert scope['type'] == 'http'
  80. await send({
  81. 'type': 'http.response.start',
  82. 'status': 200,
  83. 'headers': [
  84. (b'content-type', b'text/plain'),
  85. ],
  86. })
  87. await send({
  88. 'type': 'http.response.body',
  89. 'body': b'Hello, world!',
  90. })
  91. ```
  92. Run the server:
  93. ```shell
  94. $ uvicorn example:app
  95. ```
  96. ---
  97. ## Why ASGI?
  98. Most well established Python Web frameworks started out as WSGI-based frameworks.
  99. WSGI applications are a single, synchronous callable that takes a request and returns a response.
  100. This doesn’t allow for long-lived connections, like you get with long-poll HTTP or WebSocket connections,
  101. which WSGI doesn't support well.
  102. Having an async concurrency model also allows for options such as lightweight background tasks,
  103. and can be less of a limiting factor for endpoints that have long periods being blocked on network
  104. I/O such as dealing with slow HTTP requests.
  105. ---
  106. ## Alternative ASGI servers
  107. A strength of the ASGI protocol is that it decouples the server implementation
  108. from the application framework. This allows for an ecosystem of interoperating
  109. webservers and application frameworks.
  110. ### Daphne
  111. The first ASGI server implementation, originally developed to power Django Channels, is [the Daphne webserver][daphne].
  112. It is run widely in production, and supports HTTP/1.1, HTTP/2, and WebSockets.
  113. Any of the example applications given here can equally well be run using `daphne` instead.
  114. ```
  115. $ pip install daphne
  116. $ daphne app:App
  117. ```
  118. ### Hypercorn
  119. [Hypercorn][hypercorn] was initially part of the Quart web framework, before
  120. being separated out into a standalone ASGI server.
  121. Hypercorn supports HTTP/1.1, HTTP/2, and WebSockets.
  122. It also supports [the excellent `trio` async framework][trio], as an alternative to `asyncio`.
  123. ```
  124. $ pip install hypercorn
  125. $ hypercorn app:App
  126. ```
  127. ### Mangum
  128. [Mangum][mangum] is an adapter for using ASGI applications with AWS Lambda & API Gateway.
  129. ### Granian
  130. [Granian][granian] is an ASGI compatible Rust HTTP server which supports HTTP/2, TLS and WebSockets.
  131. ---
  132. <p align="center"><i>Uvicorn is <a href="https://github.com/Kludex/uvicorn/blob/main/LICENSE.md">BSD licensed</a> code.<br/>Designed & crafted with care.</i><br/>&mdash; 🦄 &mdash;</p>
  133. [asgi]: https://asgi.readthedocs.io/en/latest/
  134. [daphne]: https://github.com/django/daphne
  135. [hypercorn]: https://github.com/pgjones/hypercorn
  136. [trio]: https://trio.readthedocs.io
  137. [mangum]: https://github.com/jordaneremieff/mangum
  138. [granian]: https://github.com/emmett-framework/granian