METADATA 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. Metadata-Version: 2.3
  2. Name: starlette
  3. Version: 0.41.3
  4. Summary: The little ASGI library that shines.
  5. Project-URL: Homepage, https://github.com/encode/starlette
  6. Project-URL: Documentation, https://www.starlette.io/
  7. Project-URL: Changelog, https://www.starlette.io/release-notes/
  8. Project-URL: Funding, https://github.com/sponsors/encode
  9. Project-URL: Source, https://github.com/encode/starlette
  10. Author-email: Tom Christie <tom@tomchristie.com>
  11. License: BSD-3-Clause
  12. Classifier: Development Status :: 3 - Alpha
  13. Classifier: Environment :: Web Environment
  14. Classifier: Framework :: AnyIO
  15. Classifier: Intended Audience :: Developers
  16. Classifier: License :: OSI Approved :: BSD License
  17. Classifier: Operating System :: OS Independent
  18. Classifier: Programming Language :: Python :: 3
  19. Classifier: Programming Language :: Python :: 3.8
  20. Classifier: Programming Language :: Python :: 3.9
  21. Classifier: Programming Language :: Python :: 3.10
  22. Classifier: Programming Language :: Python :: 3.11
  23. Classifier: Programming Language :: Python :: 3.12
  24. Classifier: Programming Language :: Python :: 3.13
  25. Classifier: Topic :: Internet :: WWW/HTTP
  26. Requires-Python: >=3.8
  27. Requires-Dist: anyio<5,>=3.4.0
  28. Requires-Dist: typing-extensions>=3.10.0; python_version < '3.10'
  29. Provides-Extra: full
  30. Requires-Dist: httpx>=0.22.0; extra == 'full'
  31. Requires-Dist: itsdangerous; extra == 'full'
  32. Requires-Dist: jinja2; extra == 'full'
  33. Requires-Dist: python-multipart>=0.0.7; extra == 'full'
  34. Requires-Dist: pyyaml; extra == 'full'
  35. Description-Content-Type: text/markdown
  36. <p align="center">
  37. <a href="https://www.starlette.io/"><img width="420px" src="https://raw.githubusercontent.com/encode/starlette/master/docs/img/starlette.svg" alt='starlette'></a>
  38. </p>
  39. <p align="center">
  40. <em>✨ The little ASGI framework that shines. ✨</em>
  41. </p>
  42. ---
  43. [![Build Status](https://github.com/encode/starlette/workflows/Test%20Suite/badge.svg)](https://github.com/encode/starlette/actions)
  44. [![Package version](https://badge.fury.io/py/starlette.svg)](https://pypi.python.org/pypi/starlette)
  45. [![Supported Python Version](https://img.shields.io/pypi/pyversions/starlette.svg?color=%2334D058)](https://pypi.org/project/starlette)
  46. ---
  47. **Documentation**: <a href="https://www.starlette.io/" target="_blank">https://www.starlette.io</a>
  48. **Source Code**: <a href="https://github.com/encode/starlette" target="_blank">https://github.com/encode/starlette</a>
  49. ---
  50. # Starlette
  51. Starlette is a lightweight [ASGI][asgi] framework/toolkit,
  52. which is ideal for building async web services in Python.
  53. It is production-ready, and gives you the following:
  54. * A lightweight, low-complexity HTTP web framework.
  55. * WebSocket support.
  56. * In-process background tasks.
  57. * Startup and shutdown events.
  58. * Test client built on `httpx`.
  59. * CORS, GZip, Static Files, Streaming responses.
  60. * Session and Cookie support.
  61. * 100% test coverage.
  62. * 100% type annotated codebase.
  63. * Few hard dependencies.
  64. * Compatible with `asyncio` and `trio` backends.
  65. * Great overall performance [against independent benchmarks][techempower].
  66. ## Installation
  67. ```shell
  68. $ pip install starlette
  69. ```
  70. You'll also want to install an ASGI server, such as [uvicorn](https://www.uvicorn.org/), [daphne](https://github.com/django/daphne/), or [hypercorn](https://hypercorn.readthedocs.io/en/latest/).
  71. ```shell
  72. $ pip install uvicorn
  73. ```
  74. ## Example
  75. ```python title="example.py"
  76. from starlette.applications import Starlette
  77. from starlette.responses import JSONResponse
  78. from starlette.routing import Route
  79. async def homepage(request):
  80. return JSONResponse({'hello': 'world'})
  81. routes = [
  82. Route("/", endpoint=homepage)
  83. ]
  84. app = Starlette(debug=True, routes=routes)
  85. ```
  86. Then run the application using Uvicorn:
  87. ```shell
  88. $ uvicorn example:app
  89. ```
  90. For a more complete example, see [encode/starlette-example](https://github.com/encode/starlette-example).
  91. ## Dependencies
  92. Starlette only requires `anyio`, and the following are optional:
  93. * [`httpx`][httpx] - Required if you want to use the `TestClient`.
  94. * [`jinja2`][jinja2] - Required if you want to use `Jinja2Templates`.
  95. * [`python-multipart`][python-multipart] - Required if you want to support form parsing, with `request.form()`.
  96. * [`itsdangerous`][itsdangerous] - Required for `SessionMiddleware` support.
  97. * [`pyyaml`][pyyaml] - Required for `SchemaGenerator` support.
  98. You can install all of these with `pip install starlette[full]`.
  99. ## Framework or Toolkit
  100. Starlette is designed to be used either as a complete framework, or as
  101. an ASGI toolkit. You can use any of its components independently.
  102. ```python
  103. from starlette.responses import PlainTextResponse
  104. async def app(scope, receive, send):
  105. assert scope['type'] == 'http'
  106. response = PlainTextResponse('Hello, world!')
  107. await response(scope, receive, send)
  108. ```
  109. Run the `app` application in `example.py`:
  110. ```shell
  111. $ uvicorn example:app
  112. INFO: Started server process [11509]
  113. INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
  114. ```
  115. Run uvicorn with `--reload` to enable auto-reloading on code changes.
  116. ## Modularity
  117. The modularity that Starlette is designed on promotes building re-usable
  118. components that can be shared between any ASGI framework. This should enable
  119. an ecosystem of shared middleware and mountable applications.
  120. The clean API separation also means it's easier to understand each component
  121. in isolation.
  122. ---
  123. <p align="center"><i>Starlette is <a href="https://github.com/encode/starlette/blob/master/LICENSE.md">BSD licensed</a> code.<br/>Designed & crafted with care.</i></br>&mdash; ⭐️ &mdash;</p>
  124. [asgi]: https://asgi.readthedocs.io/en/latest/
  125. [httpx]: https://www.python-httpx.org/
  126. [jinja2]: https://jinja.palletsprojects.com/
  127. [python-multipart]: https://andrew-d.github.io/python-multipart/
  128. [itsdangerous]: https://itsdangerous.palletsprojects.com/
  129. [sqlalchemy]: https://www.sqlalchemy.org
  130. [pyyaml]: https://pyyaml.org/wiki/PyYAMLDocumentation
  131. [techempower]: https://www.techempower.com/benchmarks/#hw=ph&test=fortune&l=zijzen-sf