METADATA 6.4 KB

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