Async http client/server framework (asyncio)
Project description
Async http client/server framework
Key Features
Supports both client and server side of HTTP protocol.
Supports both client and server Web-Sockets out-of-the-box without the Callback Hell.
Web-server has middlewares and pluggable routing.
Getting started
Client
To retrieve something from the web:
import aiohttp
import asyncio
async def fetch(session, url):
async with session.get(url) as response:
return await response.text()
async def main():
async with aiohttp.ClientSession() as session:
html = await fetch(session, 'http://python.org')
print(html)
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Server
This is simple usage example:
from aiohttp import web
async def handle(request):
name = request.match_info.get('name', "Anonymous")
text = "Hello, " + name
return web.Response(text=text)
async def wshandle(request):
ws = web.WebSocketResponse()
await ws.prepare(request)
async for msg in ws:
if msg.type == web.WSMsgType.text:
await ws.send_str("Hello, {}".format(msg.data))
elif msg.type == web.WSMsgType.binary:
await ws.send_bytes(msg.data)
elif msg.type == web.WSMsgType.close:
break
return ws
app = web.Application()
app.add_routes([web.get('/', handle),
web.get('/echo', wshandle),
web.get('/{name}', handle)])
web.run_app(app)
Documentation
Demos
External links
Feel free to make a Pull Request for adding your link to these pages!
Communication channels
aio-libs google group: https://groups.google.com/forum/#!forum/aio-libs
Feel free to post your questions and ideas here.
gitter chat https://gitter.im/aio-libs/Lobby
We support Stack Overflow. Please add aiohttp tag to your question there.
Requirements
Python >= 3.5.3
Optionally you may install the cChardet and aiodns libraries (highly recommended for sake of speed).
License
aiohttp is offered under the Apache 2 license.
Keepsafe
The aiohttp community would like to thank Keepsafe (https://www.getkeepsafe.com) for it’s support in the early days of the project.
Source code
The latest developer version is available in a github repository: https://github.com/aio-libs/aiohttp
Benchmarks
If you are interested in by efficiency, AsyncIO community maintains a list of benchmarks on the official wiki: https://github.com/python/asyncio/wiki/Benchmarks
Changelog
3.2.0 (2018-05-06)
Features
Raise TooManyRedirects exception when client gets redirected too many times instead of returning last response. (#2631)
Extract route definitions into separate web_routedef.py file (#2876)
Raise an exception on request body reading after sending response. (#2895)
ClientResponse and RequestInfo now have real_url property, which is request url without fragment part being stripped (#2925)
Speed up connector limiting (#2937)
Added and links property for ClientResponse object (#2948)
Add request.config_dict for exposing nested applications data. (#2949)
Speed up HTTP headers serialization, server micro-benchmark runs 5% faster now. (#2957)
Apply assertions in debug mode only (#2966)
Bugfixes
expose property app for TestClient (#2891)
Call on_chunk_sent when write_eof takes as a param the last chunk (#2909)
A closing bracket was added to __repr__ of resources (#2935)
Fix compression of FileResponse (#2942)
Fixes some bugs in the limit connection feature (#2964)
Improved Documentation
Drop async_timeout usage from documentation for client API in favor of timeout parameter. (#2865)
Improve Gunicorn logging documentation (#2921)
Replace multipart writer .serialize() method with .write() in documentation. (#2965)
Deprecations and Removals
Deprecate Application.make_handler() (#2938)
Misc
#2958
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file aiohttp-3.2.0.tar.gz
.
File metadata
- Download URL: aiohttp-3.2.0.tar.gz
- Upload date:
- Size: 719.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1be3903fe6a36d20492e74efb326522dd4702bf32b45ffc7acbc0fb34ab240a6 |
|
MD5 | e4c6e2e429e4abd07f1d156879b19825 |
|
BLAKE2b-256 | 0e1bfd86244ef0c1c6c18581a7cbd37535f8a59054e73fbd52227c37b1c5a0d4 |
File details
Details for the file aiohttp-3.2.0-cp36-cp36m-win_amd64.whl
.
File metadata
- Download URL: aiohttp-3.2.0-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 419.5 kB
- Tags: CPython 3.6m, Windows x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8aa12ad9cccbdf0f896dd3f1bbe78093b09eb1a456cbd7208080c2c0e9c338e1 |
|
MD5 | 52bd74912e0f329cd497e17a271eb1e4 |
|
BLAKE2b-256 | 2a17f234a648ee32e5fe8cdd15db893c21b5c7dab302e6d903c8aa13ff310cc6 |
File details
Details for the file aiohttp-3.2.0-cp36-cp36m-win32.whl
.
File metadata
- Download URL: aiohttp-3.2.0-cp36-cp36m-win32.whl
- Upload date:
- Size: 405.5 kB
- Tags: CPython 3.6m, Windows x86
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57854a9e1f0ed26acfd5765caa5522679b6e78a4dfcd137855cd058fdae5abe2 |
|
MD5 | e8ab4068a423a5b4dfe9f26aaa3b3663 |
|
BLAKE2b-256 | 9ec556af4b0fcb6473dc0620e513c6b5ece58fc6ce34078573fc021c00b513de |
File details
Details for the file aiohttp-3.2.0-cp36-cp36m-manylinux1_x86_64.whl
.
File metadata
- Download URL: aiohttp-3.2.0-cp36-cp36m-manylinux1_x86_64.whl
- Upload date:
- Size: 761.0 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 695dc053980c9ad73030d426de40d7d0c66f4226c698b1c68ae94b9b761f28bd |
|
MD5 | 8ef2f6efb0cd6200df3066b6cde75cd5 |
|
BLAKE2b-256 | fffb33dd1b634c1aa837afce8aa259a83d6b294581442d727f13a3baf39f608c |
File details
Details for the file aiohttp-3.2.0-cp36-cp36m-manylinux1_i686.whl
.
File metadata
- Download URL: aiohttp-3.2.0-cp36-cp36m-manylinux1_i686.whl
- Upload date:
- Size: 735.5 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | af183773b170da552bfb1f78bc84647e3f7316ff5c77ae379e34362ffbafed0b |
|
MD5 | 96593b3e9593e5c449c36854e32825d4 |
|
BLAKE2b-256 | 817eaf3ecef7ad5e216efc55111043bfa600127207ea477b0604999e2d6a6b1d |
File details
Details for the file aiohttp-3.2.0-cp36-cp36m-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: aiohttp-3.2.0-cp36-cp36m-macosx_10_12_x86_64.whl
- Upload date:
- Size: 421.3 kB
- Tags: CPython 3.6m, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee39b92c1dc2425784b424bd442bd255f31e272546be92a28035dabe9da3495e |
|
MD5 | b076f1827481801397335998a0d585a4 |
|
BLAKE2b-256 | 81db93769be1bc3d1dc58b859f11a1e2eb2d1db0a8927d00ffa626ce0df70f4b |
File details
Details for the file aiohttp-3.2.0-cp36-cp36m-macosx_10_11_x86_64.whl
.
File metadata
- Download URL: aiohttp-3.2.0-cp36-cp36m-macosx_10_11_x86_64.whl
- Upload date:
- Size: 429.8 kB
- Tags: CPython 3.6m, macOS 10.11+ x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 233b9a7816d29700e4ae6e024e0cc5d9d6fbd2a9b0878d0c89b75fa708a8b204 |
|
MD5 | b42934ab5dd9965b419d7e24787c3f0d |
|
BLAKE2b-256 | 5e4702b2e08e41b25c209051ae1069743395d15bddd7a98ca5a736a7fe1a184c |
File details
Details for the file aiohttp-3.2.0-cp36-cp36m-macosx_10_10_x86_64.whl
.
File metadata
- Download URL: aiohttp-3.2.0-cp36-cp36m-macosx_10_10_x86_64.whl
- Upload date:
- Size: 431.8 kB
- Tags: CPython 3.6m, macOS 10.10+ x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 424ad41a5434c25920fc8d0ce24c2f8d749965bce8996b86c9be0cd50f0051b2 |
|
MD5 | c89ffba459358a63f534a907b956eb28 |
|
BLAKE2b-256 | 5dc051a3ac413149913a7dab019e5b5bb464c4e7fc04868515158e59dcc7ba6b |
File details
Details for the file aiohttp-3.2.0-cp35-cp35m-win_amd64.whl
.
File metadata
- Download URL: aiohttp-3.2.0-cp35-cp35m-win_amd64.whl
- Upload date:
- Size: 417.6 kB
- Tags: CPython 3.5m, Windows x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51652ba1310e5a71a20133976ae6cbe301edce3387c6d3df4a8451841af8c9c7 |
|
MD5 | 58c0ad4f4599194e1504581ddb782284 |
|
BLAKE2b-256 | 3cd3aff2e50a3233271581963531b6406f2291129b7321faef3d47062d71b048 |
File details
Details for the file aiohttp-3.2.0-cp35-cp35m-win32.whl
.
File metadata
- Download URL: aiohttp-3.2.0-cp35-cp35m-win32.whl
- Upload date:
- Size: 403.9 kB
- Tags: CPython 3.5m, Windows x86
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6abeb48f66ac26690fb681cc3c1f9eed1d2f9f29b7cd4f3e182d3276001f663 |
|
MD5 | 025ba9d0e23da766519869f357966a87 |
|
BLAKE2b-256 | d247d063068486ae7e096d0160452c0101ce50c4fb2e3b43d4b612eb9994954d |
File details
Details for the file aiohttp-3.2.0-cp35-cp35m-manylinux1_x86_64.whl
.
File metadata
- Download URL: aiohttp-3.2.0-cp35-cp35m-manylinux1_x86_64.whl
- Upload date:
- Size: 745.5 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef885a19bcff2a20ae0362ab6b8f8ac62b8bd8490dd3e031f15933abbe41d2b2 |
|
MD5 | 1a9b1bb48dcbb41f8ac3149e873fcf13 |
|
BLAKE2b-256 | 059aeded1423b19063c8a06457a0bfd69a070b320f1fba67797449e65dc7ffa2 |
File details
Details for the file aiohttp-3.2.0-cp35-cp35m-manylinux1_i686.whl
.
File metadata
- Download URL: aiohttp-3.2.0-cp35-cp35m-manylinux1_i686.whl
- Upload date:
- Size: 720.0 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4af32e7641f8029fd2cb6b3d3e51e92074ae0d42347d56e93b25fbb3f49a43bb |
|
MD5 | c4d1b5e4e494b5f02916f940ad723dd9 |
|
BLAKE2b-256 | 929c2bf432249bb57bf87e07842b458fac130d44dd7d8fb536154ac3edf46bc7 |
File details
Details for the file aiohttp-3.2.0-cp35-cp35m-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: aiohttp-3.2.0-cp35-cp35m-macosx_10_12_x86_64.whl
- Upload date:
- Size: 420.5 kB
- Tags: CPython 3.5m, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7dc80c5984613a30a6608718a401143598f69907770a46e5b6df87c7b9d06ce8 |
|
MD5 | abcebb2b6d30639ae56a4b3fc526a649 |
|
BLAKE2b-256 | 60e0019b121318c065e26cdae8ecc9e6f40a32a9dcbee9669d3d5f80b98b13a3 |
File details
Details for the file aiohttp-3.2.0-cp35-cp35m-macosx_10_11_x86_64.whl
.
File metadata
- Download URL: aiohttp-3.2.0-cp35-cp35m-macosx_10_11_x86_64.whl
- Upload date:
- Size: 427.4 kB
- Tags: CPython 3.5m, macOS 10.11+ x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46c004a3bd91c42caa1bb9c4d44ef156ccf0d7f56272590da8d066710e7c63be |
|
MD5 | fa848d3225b12cf1cb0cafb29c695ad2 |
|
BLAKE2b-256 | 7f3d357cc50078db44388b1f451fda586a45bb852aaf4cd876808c481cfaa6d6 |
File details
Details for the file aiohttp-3.2.0-cp35-cp35m-macosx_10_10_x86_64.whl
.
File metadata
- Download URL: aiohttp-3.2.0-cp35-cp35m-macosx_10_10_x86_64.whl
- Upload date:
- Size: 429.1 kB
- Tags: CPython 3.5m, macOS 10.10+ x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b034ab3a8e328705625467fe7b3a59e23da6952ba19b5a14b044aef206b653fa |
|
MD5 | 6af3692e2c395ae0936eb4c61edeae7a |
|
BLAKE2b-256 | 4abdf57b6d6bb99df7d82b68f48a1713cf3dd6d5fc3e711e1e5c205ad1a81da0 |