Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

177 řádky
6.0 KiB

  1. Metadata-Version: 2.4
  2. Name: starlette
  3. Version: 0.47.2
  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-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: Topic :: Internet :: WWW/HTTP
  26. Requires-Python: >=3.9
  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: httpx<0.29.0,>=0.27.0; extra == 'full'
  31. Requires-Dist: itsdangerous; extra == 'full'
  32. Requires-Dist: jinja2; extra == 'full'
  33. Requires-Dist: python-multipart>=0.0.18; extra == 'full'
  34. Requires-Dist: pyyaml; extra == 'full'
  35. Description-Content-Type: text/markdown
  36. <p align="center">
  37. <picture>
  38. <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/encode/starlette/master/docs/img/starlette_dark.svg" width="420px">
  39. <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/encode/starlette/master/docs/img/starlette.svg" width="420px">
  40. <img alt="starlette-logo" src="https://raw.githubusercontent.com/encode/starlette/master/docs/img/starlette_dark.svg">
  41. </picture>
  42. </p>
  43. <p align="center">
  44. <em>✨ The little ASGI framework that shines. ✨</em>
  45. </p>
  46. ---
  47. [![Build Status](https://github.com/encode/starlette/workflows/Test%20Suite/badge.svg)](https://github.com/encode/starlette/actions)
  48. [![Package version](https://badge.fury.io/py/starlette.svg)](https://pypi.python.org/pypi/starlette)
  49. [![Supported Python Version](https://img.shields.io/pypi/pyversions/starlette.svg?color=%2334D058)](https://pypi.org/project/starlette)
  50. ---
  51. **Documentation**: <a href="https://www.starlette.io/" target="_blank">https://www.starlette.io</a>
  52. **Source Code**: <a href="https://github.com/encode/starlette" target="_blank">https://github.com/encode/starlette</a>
  53. ---
  54. # Starlette
  55. Starlette is a lightweight [ASGI][asgi] framework/toolkit,
  56. which is ideal for building async web services in Python.
  57. It is production-ready, and gives you the following:
  58. * A lightweight, low-complexity HTTP web framework.
  59. * WebSocket support.
  60. * In-process background tasks.
  61. * Startup and shutdown events.
  62. * Test client built on `httpx`.
  63. * CORS, GZip, Static Files, Streaming responses.
  64. * Session and Cookie support.
  65. * 100% test coverage.
  66. * 100% type annotated codebase.
  67. * Few hard dependencies.
  68. * Compatible with `asyncio` and `trio` backends.
  69. * Great overall performance [against independent benchmarks][techempower].
  70. ## Installation
  71. ```shell
  72. $ pip install starlette
  73. ```
  74. 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/).
  75. ```shell
  76. $ pip install uvicorn
  77. ```
  78. ## Example
  79. ```python title="main.py"
  80. from starlette.applications import Starlette
  81. from starlette.responses import JSONResponse
  82. from starlette.routing import Route
  83. async def homepage(request):
  84. return JSONResponse({'hello': 'world'})
  85. routes = [
  86. Route("/", endpoint=homepage)
  87. ]
  88. app = Starlette(debug=True, routes=routes)
  89. ```
  90. Then run the application using Uvicorn:
  91. ```shell
  92. $ uvicorn main:app
  93. ```
  94. ## Dependencies
  95. Starlette only requires `anyio`, and the following are optional:
  96. * [`httpx`][httpx] - Required if you want to use the `TestClient`.
  97. * [`jinja2`][jinja2] - Required if you want to use `Jinja2Templates`.
  98. * [`python-multipart`][python-multipart] - Required if you want to support form parsing, with `request.form()`.
  99. * [`itsdangerous`][itsdangerous] - Required for `SessionMiddleware` support.
  100. * [`pyyaml`][pyyaml] - Required for `SchemaGenerator` support.
  101. You can install all of these with `pip install starlette[full]`.
  102. ## Framework or Toolkit
  103. Starlette is designed to be used either as a complete framework, or as
  104. an ASGI toolkit. You can use any of its components independently.
  105. ```python
  106. from starlette.responses import PlainTextResponse
  107. async def app(scope, receive, send):
  108. assert scope['type'] == 'http'
  109. response = PlainTextResponse('Hello, world!')
  110. await response(scope, receive, send)
  111. ```
  112. Run the `app` application in `example.py`:
  113. ```shell
  114. $ uvicorn example:app
  115. INFO: Started server process [11509]
  116. INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
  117. ```
  118. Run uvicorn with `--reload` to enable auto-reloading on code changes.
  119. ## Modularity
  120. The modularity that Starlette is designed on promotes building re-usable
  121. components that can be shared between any ASGI framework. This should enable
  122. an ecosystem of shared middleware and mountable applications.
  123. The clean API separation also means it's easier to understand each component
  124. in isolation.
  125. ---
  126. <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>
  127. [asgi]: https://asgi.readthedocs.io/en/latest/
  128. [httpx]: https://www.python-httpx.org/
  129. [jinja2]: https://jinja.palletsprojects.com/
  130. [python-multipart]: https://multipart.fastapiexpert.com/
  131. [itsdangerous]: https://itsdangerous.palletsprojects.com/
  132. [sqlalchemy]: https://www.sqlalchemy.org
  133. [pyyaml]: https://pyyaml.org/wiki/PyYAMLDocumentation
  134. [techempower]: https://www.techempower.com/benchmarks/#hw=ph&test=fortune&l=zijzen-sf