| 1 |
Metadata-Version: 2.1 |
| 2 |
Name: aiohttp |
| 3 |
Version: 3.10.11 |
| 4 |
Summary: Async http client/server framework (asyncio) |
| 5 |
Home-page: https://github.com/aio-libs/aiohttp |
| 6 |
Maintainer: aiohttp team <[email protected]> |
| 7 |
Maintainer-email: [email protected] |
| 8 |
License: Apache 2 |
| 9 |
Project-URL: Chat: Matrix, https://matrix.to/#/#aio-libs:matrix.org |
| 10 |
Project-URL: Chat: Matrix Space, https://matrix.to/#/#aio-libs-space:matrix.org |
| 11 |
Project-URL: CI: GitHub Actions, https://github.com/aio-libs/aiohttp/actions?query=workflow%3ACI |
| 12 |
Project-URL: Coverage: codecov, https://codecov.io/github/aio-libs/aiohttp |
| 13 |
Project-URL: Docs: Changelog, https://docs.aiohttp.org/en/stable/changes.html |
| 14 |
Project-URL: Docs: RTD, https://docs.aiohttp.org |
| 15 |
Project-URL: GitHub: issues, https://github.com/aio-libs/aiohttp/issues |
| 16 |
Project-URL: GitHub: repo, https://github.com/aio-libs/aiohttp |
| 17 |
Classifier: Development Status :: 5 - Production/Stable |
| 18 |
Classifier: Framework :: AsyncIO |
| 19 |
Classifier: Intended Audience :: Developers |
| 20 |
Classifier: License :: OSI Approved :: Apache Software License |
| 21 |
Classifier: Operating System :: POSIX |
| 22 |
Classifier: Operating System :: MacOS :: MacOS X |
| 23 |
Classifier: Operating System :: Microsoft :: Windows |
| 24 |
Classifier: Programming Language :: Python |
| 25 |
Classifier: Programming Language :: Python :: 3 |
| 26 |
Classifier: Programming Language :: Python :: 3.8 |
| 27 |
Classifier: Programming Language :: Python :: 3.9 |
| 28 |
Classifier: Programming Language :: Python :: 3.10 |
| 29 |
Classifier: Programming Language :: Python :: 3.11 |
| 30 |
Classifier: Programming Language :: Python :: 3.12 |
| 31 |
Classifier: Programming Language :: Python :: 3.13 |
| 32 |
Classifier: Topic :: Internet :: WWW/HTTP |
| 33 |
Requires-Python: >=3.8 |
| 34 |
Description-Content-Type: text/x-rst |
| 35 |
License-File: LICENSE.txt |
| 36 |
Requires-Dist: aiohappyeyeballs>=2.3.0 |
| 37 |
Requires-Dist: aiosignal>=1.1.2 |
| 38 |
Requires-Dist: async-timeout<6.0,>=4.0; python_version < "3.11" |
| 39 |
Requires-Dist: attrs>=17.3.0 |
| 40 |
Requires-Dist: frozenlist>=1.1.1 |
| 41 |
Requires-Dist: multidict<7.0,>=4.5 |
| 42 |
Requires-Dist: yarl<2.0,>=1.12.0 |
| 43 |
Provides-Extra: speedups |
| 44 |
Requires-Dist: aiodns>=3.2.0; (sys_platform == "linux" or sys_platform == "darwin") and extra == "speedups" |
| 45 |
Requires-Dist: Brotli; platform_python_implementation == "CPython" and extra == "speedups" |
| 46 |
Requires-Dist: brotlicffi; platform_python_implementation != "CPython" and extra == "speedups" |
| 47 |
|
| 48 |
================================== |
| 49 |
Async http client/server framework |
| 50 |
================================== |
| 51 |
|
| 52 |
.. image:: https://raw.githubusercontent.com/aio-libs/aiohttp/master/docs/aiohttp-plain.svg |
| 53 |
:height: 64px |
| 54 |
:width: 64px |
| 55 |
:alt: aiohttp logo |
| 56 |
|
| 57 |
| |
| 58 |
|
| 59 |
.. image:: https://github.com/aio-libs/aiohttp/workflows/CI/badge.svg |
| 60 |
:target: https://github.com/aio-libs/aiohttp/actions?query=workflow%3ACI |
| 61 |
:alt: GitHub Actions status for master branch |
| 62 |
|
| 63 |
.. image:: https://codecov.io/gh/aio-libs/aiohttp/branch/master/graph/badge.svg |
| 64 |
:target: https://codecov.io/gh/aio-libs/aiohttp |
| 65 |
:alt: codecov.io status for master branch |
| 66 |
|
| 67 |
.. image:: https://img.shields.io/endpoint?url=https://codspeed.io/badge.json |
| 68 |
:target: https://codspeed.io/aio-libs/aiohttp |
| 69 |
:alt: Codspeed.io status for aiohttp |
| 70 |
|
| 71 |
.. image:: https://badge.fury.io/py/aiohttp.svg |
| 72 |
:target: https://pypi.org/project/aiohttp |
| 73 |
:alt: Latest PyPI package version |
| 74 |
|
| 75 |
.. image:: https://readthedocs.org/projects/aiohttp/badge/?version=latest |
| 76 |
:target: https://docs.aiohttp.org/ |
| 77 |
:alt: Latest Read The Docs |
| 78 |
|
| 79 |
.. image:: https://img.shields.io/matrix/aio-libs:matrix.org?label=Discuss%20on%20Matrix%20at%20%23aio-libs%3Amatrix.org&logo=matrix&server_fqdn=matrix.org&style=flat |
| 80 |
:target: https://matrix.to/#/%23aio-libs:matrix.org |
| 81 |
:alt: Matrix Room — #aio-libs:matrix.org |
| 82 |
|
| 83 |
.. image:: https://img.shields.io/matrix/aio-libs-space:matrix.org?label=Discuss%20on%20Matrix%20at%20%23aio-libs-space%3Amatrix.org&logo=matrix&server_fqdn=matrix.org&style=flat |
| 84 |
:target: https://matrix.to/#/%23aio-libs-space:matrix.org |
| 85 |
:alt: Matrix Space — #aio-libs-space:matrix.org |
| 86 |
|
| 87 |
|
| 88 |
Key Features |
| 89 |
============ |
| 90 |
|
| 91 |
- Supports both client and server side of HTTP protocol. |
| 92 |
- Supports both client and server Web-Sockets out-of-the-box and avoids |
| 93 |
Callback Hell. |
| 94 |
- Provides Web-server with middleware and pluggable routing. |
| 95 |
|
| 96 |
|
| 97 |
Getting started |
| 98 |
=============== |
| 99 |
|
| 100 |
Client |
| 101 |
------ |
| 102 |
|
| 103 |
To get something from the web: |
| 104 |
|
| 105 |
.. code-block:: python |
| 106 |
|
| 107 |
import aiohttp |
| 108 |
import asyncio |
| 109 |
|
| 110 |
async def main(): |
| 111 |
|
| 112 |
async with aiohttp.ClientSession() as session: |
| 113 |
async with session.get('http://python.org') as response: |
| 114 |
|
| 115 |
print("Status:", response.status) |
| 116 |
print("Content-type:", response.headers['content-type']) |
| 117 |
|
| 118 |
html = await response.text() |
| 119 |
print("Body:", html[:15], "...") |
| 120 |
|
| 121 |
asyncio.run(main()) |
| 122 |
|
| 123 |
This prints: |
| 124 |
|
| 125 |
.. code-block:: |
| 126 |
|
| 127 |
Status: 200 |
| 128 |
Content-type: text/html; charset=utf-8 |
| 129 |
Body: <!doctype html> ... |
| 130 |
|
| 131 |
Coming from `requests <https://requests.readthedocs.io/>`_ ? Read `why we need so many lines <https://aiohttp.readthedocs.io/en/latest/http_request_lifecycle.html>`_. |
| 132 |
|
| 133 |
Server |
| 134 |
------ |
| 135 |
|
| 136 |
An example using a simple server: |
| 137 |
|
| 138 |
.. code-block:: python |
| 139 |
|
| 140 |
# examples/server_simple.py |
| 141 |
from aiohttp import web |
| 142 |
|
| 143 |
async def handle(request): |
| 144 |
name = request.match_info.get('name', "Anonymous") |
| 145 |
text = "Hello, " + name |
| 146 |
return web.Response(text=text) |
| 147 |
|
| 148 |
async def wshandle(request): |
| 149 |
ws = web.WebSocketResponse() |
| 150 |
await ws.prepare(request) |
| 151 |
|
| 152 |
async for msg in ws: |
| 153 |
if msg.type == web.WSMsgType.text: |
| 154 |
await ws.send_str("Hello, {}".format(msg.data)) |
| 155 |
elif msg.type == web.WSMsgType.binary: |
| 156 |
await ws.send_bytes(msg.data) |
| 157 |
elif msg.type == web.WSMsgType.close: |
| 158 |
break |
| 159 |
|
| 160 |
return ws |
| 161 |
|
| 162 |
|
| 163 |
app = web.Application() |
| 164 |
app.add_routes([web.get('/', handle), |
| 165 |
web.get('/echo', wshandle), |
| 166 |
web.get('/{name}', handle)]) |
| 167 |
|
| 168 |
if __name__ == '__main__': |
| 169 |
web.run_app(app) |
| 170 |
|
| 171 |
|
| 172 |
Documentation |
| 173 |
============= |
| 174 |
|
| 175 |
https://aiohttp.readthedocs.io/ |
| 176 |
|
| 177 |
|
| 178 |
Demos |
| 179 |
===== |
| 180 |
|
| 181 |
https://github.com/aio-libs/aiohttp-demos |
| 182 |
|
| 183 |
|
| 184 |
External links |
| 185 |
============== |
| 186 |
|
| 187 |
* `Third party libraries |
| 188 |
<http://aiohttp.readthedocs.io/en/latest/third_party.html>`_ |
| 189 |
* `Built with aiohttp |
| 190 |
<http://aiohttp.readthedocs.io/en/latest/built_with.html>`_ |
| 191 |
* `Powered by aiohttp |
| 192 |
<http://aiohttp.readthedocs.io/en/latest/powered_by.html>`_ |
| 193 |
|
| 194 |
Feel free to make a Pull Request for adding your link to these pages! |
| 195 |
|
| 196 |
|
| 197 |
Communication channels |
| 198 |
====================== |
| 199 |
|
| 200 |
*aio-libs Discussions*: https://github.com/aio-libs/aiohttp/discussions |
| 201 |
|
| 202 |
*Matrix*: `#aio-libs:matrix.org <https://matrix.to/#/#aio-libs:matrix.org>`_ |
| 203 |
|
| 204 |
We support `Stack Overflow |
| 205 |
<https://stackoverflow.com/questions/tagged/aiohttp>`_. |
| 206 |
Please add *aiohttp* tag to your question there. |
| 207 |
|
| 208 |
Requirements |
| 209 |
============ |
| 210 |
|
| 211 |
- attrs_ |
| 212 |
- multidict_ |
| 213 |
- yarl_ |
| 214 |
- frozenlist_ |
| 215 |
|
| 216 |
Optionally you may install the aiodns_ library (highly recommended for sake of speed). |
| 217 |
|
| 218 |
.. _aiodns: https://pypi.python.org/pypi/aiodns |
| 219 |
.. _attrs: https://github.com/python-attrs/attrs |
| 220 |
.. _multidict: https://pypi.python.org/pypi/multidict |
| 221 |
.. _frozenlist: https://pypi.org/project/frozenlist/ |
| 222 |
.. _yarl: https://pypi.python.org/pypi/yarl |
| 223 |
.. _async-timeout: https://pypi.python.org/pypi/async_timeout |
| 224 |
|
| 225 |
License |
| 226 |
======= |
| 227 |
|
| 228 |
``aiohttp`` is offered under the Apache 2 license. |
| 229 |
|
| 230 |
|
| 231 |
Keepsafe |
| 232 |
======== |
| 233 |
|
| 234 |
The aiohttp community would like to thank Keepsafe |
| 235 |
(https://www.getkeepsafe.com) for its support in the early days of |
| 236 |
the project. |
| 237 |
|
| 238 |
|
| 239 |
Source code |
| 240 |
=========== |
| 241 |
|
| 242 |
The latest developer version is available in a GitHub repository: |
| 243 |
https://github.com/aio-libs/aiohttp |
| 244 |
|
| 245 |
Benchmarks |
| 246 |
========== |
| 247 |
|
| 248 |
If you are interested in efficiency, the AsyncIO community maintains a |
| 249 |
list of benchmarks on the official wiki: |
| 250 |
https://github.com/python/asyncio/wiki/Benchmarks |