Metadata-Version: 2.4
Name: asgi-tools
Version: 3.2.1
Summary: ASGI Toolkit to build web applications
Author-email: Kirill Klenov <horneds@gmail.com>
License: MIT License
Project-URL: homepage, https://github.com/klen/asgi-tools
Project-URL: repository, https://github.com/klen/asgi-tools
Project-URL: documentation, https://klen.github.io/asgi-tools
Keywords: asgi,asgi-tools,request,response,asyncio,trio
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Programming Language :: Cython
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Framework :: AsyncIO
Classifier: Framework :: Trio
Requires-Python: <4,>=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: http-router>=8.0.0
Requires-Dist: multidict>=6.6.3
Requires-Dist: sniffio
Requires-Dist: yarl>=1.8.2
Provides-Extra: tests
Requires-Dist: aiofile; extra == "tests"
Requires-Dist: pytest; extra == "tests"
Requires-Dist: pytest-aio[curio,trio]>=2; extra == "tests"
Requires-Dist: pytest-benchmark; extra == "tests"
Requires-Dist: PyYAML; extra == "tests"
Requires-Dist: ruff; extra == "tests"
Requires-Dist: mypy; extra == "tests"
Requires-Dist: orjson; implementation_name == "cpython" and extra == "tests"
Requires-Dist: uvloop; implementation_name == "cpython" and extra == "tests"
Requires-Dist: pytest-mypy; implementation_name == "cpython" and extra == "tests"
Provides-Extra: orjson
Requires-Dist: orjson; extra == "orjson"
Provides-Extra: examples
Requires-Dist: uvicorn[standard]; extra == "examples"
Requires-Dist: jinja2; extra == "examples"
Requires-Dist: httpx; extra == "examples"
Provides-Extra: dev
Requires-Dist: bump2version; extra == "dev"
Requires-Dist: tox; extra == "dev"
Requires-Dist: cython; extra == "dev"
Requires-Dist: pre-commit; extra == "dev"
Requires-Dist: sphinx; extra == "dev"
Requires-Dist: pydata-sphinx-theme; extra == "dev"
Requires-Dist: sphinx-copybutton; extra == "dev"
Dynamic: license-file

# ASGI-Tools

![ASGI-Tools][logo]

**asgi-tools** is a lightweight [ASGI][asgi-spec] toolkit for building ASGI applications faster.

[![Tests Status][tests-badge]][tests-url] [![Documentation Status][docs-badge]][docs-url]
[![PyPI Version][pypi-badge]][pypi-url] [![Python Versions][pyversions-badge]][pypi-url]

Full documentation: <https://klen.github.io/asgi-tools>

ASGI-Tools is a toolkit to quickly build lightweight ASGI applications, middlewares and tools.
For instance, these middlewares were built with it:

- [ASGI-Sessions](https://github.com/klen/asgi-sessions)
- [ASGI-Babel](https://github.com/klen/asgi-babel)
- [ASGI-Prometheus](https://github.com/klen/asgi-prometheus)

## Features

- Supports the most popular async Python libraries: [Asyncio][asyncio],
  [Trio][trio], and [Curio][curio]
- [Request][request]: parse the ASGI scope and get the url, headers, cookies,
  data, json or form data
- [Response][responses]: send HTTP (text, html, json, stream, SSE, file, http
  errors) responses
- [ResponseWebSocket][websocket]: work with websockets
- [RequestMiddleware][requestmw]: parse a scope and insert the parsed request
  into the scope
- [ResponseMiddleware][responsemw]: parse responses and convert them into ASGI
  messages
- [RouterMiddleware][routermw]: route HTTP requests
- [LifespanMiddleware][lifespanmw]: process a lifespan cycle
- [StaticFilesMiddleware][staticmw]: serve static files from URL prefixes
- [ASGITestClient][testclient]: a test client with websockets support to test
  ASGI applications
- [App][app]: a simple foundation for ASGI apps

## Requirements

Python 3.11 or newer.
PyPy3 is also supported.

ASGI-Tools belongs to the category of ASGI web frameworks, so it requires an ASGI HTTP server to run,
such as [uvicorn][uvicorn], [daphne][daphne], or [hypercorn][hypercorn].

## Installation

Install with pip:

```sh
pip install asgi-tools
```

## Quick Example

You can use any ASGI-Tools component independently.
The library also includes an [App][app] helper to quickly build ASGI applications.

Save this to `app.py`:

```python
from asgi_tools import App

app = App()


@app.route("/")
async def hello(request):
    return "Hello World!"
```

Run it with `uvicorn`:

```sh
uvicorn app:app
```

## Bug tracker

If you have any suggestions, bug reports, or annoyances, report them to the [issue tracker][issues].

## Contributing

Development of the project happens at <https://github.com/klen/asgi-tools>.

## License

Licensed under the [MIT license][mit].

[logo]: https://raw.githubusercontent.com/klen/asgi-tools/develop/.github/assets/asgi-tools.png
[tests-badge]: https://github.com/klen/asgi-tools/workflows/tests/badge.svg
[tests-url]: https://github.com/klen/asgi-tools/actions
[docs-badge]: https://github.com/klen/asgi-tools/workflows/docs/badge.svg
[docs-url]: https://klen.github.io/asgi-tools
[pypi-badge]: https://img.shields.io/pypi/v/asgi-tools
[pypi-url]: https://pypi.org/project/asgi-tools/
[pyversions-badge]: https://img.shields.io/pypi/pyversions/asgi-tools
[asgi-spec]: https://asgi.readthedocs.io/en/latest/
[asyncio]: https://docs.python.org/3/library/asyncio.html
[trio]: https://trio.readthedocs.io/en/stable/index.html
[curio]: https://github.com/dabeaz/curio
[request]: https://klen.github.io/asgi-tools/api.html#request
[responses]: https://klen.github.io/asgi-tools/api.html#responses
[websocket]: https://klen.github.io/asgi-tools/api.html#responsewebsocket
[requestmw]: https://klen.github.io/asgi-tools/api.html#requestmiddleware
[responsemw]: https://klen.github.io/asgi-tools/api.html#responsemiddleware
[routermw]: https://klen.github.io/asgi-tools/api.html#routermiddleware
[lifespanmw]: https://klen.github.io/asgi-tools/api.html#lifespanmiddleware
[staticmw]: https://klen.github.io/asgi-tools/api.html#staticfilesmiddleware
[testclient]: https://klen.github.io/asgi-tools/api.html#asgi_tools.tests.ASGITestClient
[app]: https://klen.github.io/asgi-tools/api.html#application
[uvicorn]: http://www.uvicorn.org/
[daphne]: https://github.com/django/daphne/
[hypercorn]: https://github.com/pgjones/hypercorn/
[issues]: https://github.com/klen/asgi-tools/issues
[mit]: http://opensource.org/licenses/MIT
