METADATA 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. Metadata-Version: 2.4
  2. Name: starlette
  3. Version: 0.48.0
  4. Summary: The little ASGI library that shines.
  5. Project-URL: Homepage, https://github.com/Kludex/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/Kludex
  9. Project-URL: Source, https://github.com/Kludex/starlette
  10. Author-email: Tom Christie <tom@tomchristie.com>, Marcelo Trylesinski <marcelotryle@gmail.com>
  11. License-Expression: BSD-3-Clause
  12. License-File: LICENSE.md
  13. Classifier: Development Status :: 3 - Alpha
  14. Classifier: Environment :: Web Environment
  15. Classifier: Framework :: AnyIO
  16. Classifier: Intended Audience :: Developers
  17. Classifier: License :: OSI Approved :: BSD License
  18. Classifier: Operating System :: OS Independent
  19. Classifier: Programming Language :: Python :: 3
  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: Programming Language :: Python :: 3.14
  26. Classifier: Topic :: Internet :: WWW/HTTP
  27. Requires-Python: >=3.9
  28. Requires-Dist: anyio<5,>=3.6.2
  29. Requires-Dist: typing-extensions>=4.10.0; python_version < '3.13'
  30. Provides-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_dark.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. ---
  52. **Documentation**: <a href="https://www.starlette.io/" target="_blank">https://www.starlette.io</a>
  53. **Source Code**: <a href="https://github.com/Kludex/starlette" target="_blank">https://github.com/Kludex/starlette</a>
  54. ---
  55. # Starlette
  56. Starlette is a lightweight [ASGI][asgi] framework/toolkit,
  57. which is ideal for building async web services in Python.
  58. It is production-ready, and gives you the following:
  59. * A lightweight, low-complexity HTTP web framework.
  60. * WebSocket support.
  61. * In-process background tasks.
  62. * Startup and shutdown events.
  63. * Test client built on `httpx`.
  64. * CORS, GZip, Static Files, Streaming responses.
  65. * Session and Cookie support.
  66. * 100% test coverage.
  67. * 100% type annotated codebase.
  68. * Few hard dependencies.
  69. * Compatible with `asyncio` and `trio` backends.
  70. * Great overall performance [against independent benchmarks][techempower].
  71. ## Installation
  72. ```shell
  73. $ pip install starlette
  74. ```
  75. 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/).
  76. ```shell
  77. $ pip install uvicorn
  78. ```
  79. ## Example
  80. ```python title="main.py"
  81. from starlette.applications import Starlette
  82. from starlette.responses import JSONResponse
  83. from starlette.routing import Route
  84. async def homepage(request):
  85. return JSONResponse({'hello': 'world'})
  86. routes = [
  87. Route("/", endpoint=homepage)
  88. ]
  89. app = Starlette(debug=True, routes=routes)
  90. ```
  91. Then run the application using Uvicorn:
  92. ```shell
  93. $ uvicorn main:app
  94. ```
  95. ## Dependencies
  96. Starlette only requires `anyio`, and the following are optional:
  97. * [`httpx`][httpx] - Required if you want to use the `TestClient`.
  98. * [`jinja2`][jinja2] - Required if you want to use `Jinja2Templates`.
  99. * [`python-multipart`][python-multipart] - Required if you want to support form parsing, with `request.form()`.
  100. * [`itsdangerous`][itsdangerous] - Required for `SessionMiddleware` support.
  101. * [`pyyaml`][pyyaml] - Required for `SchemaGenerator` support.
  102. You can install all of these with `pip install starlette[full]`.
  103. ## Framework or Toolkit
  104. Starlette is designed to be used either as a complete framework, or as
  105. an ASGI toolkit. You can use any of its components independently.
  106. ```python
  107. from starlette.responses import PlainTextResponse
  108. async def app(scope, receive, send):
  109. assert scope['type'] == 'http'
  110. response = PlainTextResponse('Hello, world!')
  111. await response(scope, receive, send)
  112. ```
  113. Run the `app` application in `example.py`:
  114. ```shell
  115. $ uvicorn example:app
  116. INFO: Started server process [11509]
  117. INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
  118. ```
  119. Run uvicorn with `--reload` to enable auto-reloading on code changes.
  120. ## Modularity
  121. The modularity that Starlette is designed on promotes building re-usable
  122. components that can be shared between any ASGI framework. This should enable
  123. an ecosystem of shared middleware and mountable applications.
  124. The clean API separation also means it's easier to understand each component
  125. in isolation.
  126. ---
  127. <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>
  128. [asgi]: https://asgi.readthedocs.io/en/latest/
  129. [httpx]: https://www.python-httpx.org/
  130. [jinja2]: https://jinja.palletsprojects.com/
  131. [python-multipart]: https://multipart.fastapiexpert.com/
  132. [itsdangerous]: https://itsdangerous.palletsprojects.com/
  133. [sqlalchemy]: https://www.sqlalchemy.org
  134. [pyyaml]: https://pyyaml.org/wiki/PyYAMLDocumentation
  135. [techempower]: https://www.techempower.com/benchmarks/#hw=ph&test=fortune&l=zijzen-sf