METADATA 6.2 KB

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