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.1 (2018-05-10)
Don’t reuse a connection with the same URL but different proxy/TLS settings (#2981)
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
Improved Documentation
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.1.tar.gz
.
File metadata
- Download URL: aiohttp-3.2.1.tar.gz
- Upload date:
- Size: 720.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b95d53f8dac13898f0a3e4af76f6f36d540fbfaefc4f4c9f43e436fa0e53d22 |
|
MD5 | 323488a14b46ba289415eb290088f8fe |
|
BLAKE2b-256 | 81fa8915137ac0603112bbb63489de90a75c69da8a138594eb6a24cb8afb14df |
File details
Details for the file aiohttp-3.2.1-cp36-cp36m-win_amd64.whl
.
File metadata
- Download URL: aiohttp-3.2.1-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 419.8 kB
- Tags: CPython 3.6m, Windows x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92b3aaa2896109be9a477f8a57314a144c9d56c6b7e16183e43e5fcad5e89da8 |
|
MD5 | eb71d7e63611a35146f2f04aebaf52b2 |
|
BLAKE2b-256 | 552e3f1d940482e9d4a201b7d457dd2e1cc77a19ea9ff40fc2088410893f0e4b |
File details
Details for the file aiohttp-3.2.1-cp36-cp36m-win32.whl
.
File metadata
- Download URL: aiohttp-3.2.1-cp36-cp36m-win32.whl
- Upload date:
- Size: 405.9 kB
- Tags: CPython 3.6m, Windows x86
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d51800bdc01d9c1c70fa3ed394a1755f93464354b04039b41d48ce1308517e81 |
|
MD5 | 04ddfab89b0009be98dc7a5d1e2c6976 |
|
BLAKE2b-256 | e89517b21b03f408fef260f93816cb427882a289984929612edb8f1801c5f36b |
File details
Details for the file aiohttp-3.2.1-cp36-cp36m-manylinux1_x86_64.whl
.
File metadata
- Download URL: aiohttp-3.2.1-cp36-cp36m-manylinux1_x86_64.whl
- Upload date:
- Size: 761.3 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ba1394d3eea2a3e2641e9a93a95b6d8b09478ef1d2ce2845e0ee1511a2937d2 |
|
MD5 | da3e17abc3f395c816dcc0afc935117b |
|
BLAKE2b-256 | 7527d76236fb1620eba35d6f5c60eaa08de36256a6c8e6516b3e132868b51509 |
File details
Details for the file aiohttp-3.2.1-cp36-cp36m-manylinux1_i686.whl
.
File metadata
- Download URL: aiohttp-3.2.1-cp36-cp36m-manylinux1_i686.whl
- Upload date:
- Size: 735.8 kB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 862c5694a192a18cbcf3553fdff121aa9abe1b4edd65af7953b258211808437d |
|
MD5 | 6ad2e3ff74f23f2779bdbe606dbd95cd |
|
BLAKE2b-256 | a31060c12d16a5c6a87cd11d3df3a1a02f0f8ea8a9592b9dea4b8ba7f13f77df |
File details
Details for the file aiohttp-3.2.1-cp36-cp36m-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: aiohttp-3.2.1-cp36-cp36m-macosx_10_12_x86_64.whl
- Upload date:
- Size: 421.6 kB
- Tags: CPython 3.6m, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 359d3e7dfe9f0f6d8c6105152d6fbc45027992f40bdf971484dbc5e7dc7c456f |
|
MD5 | 8270113d9307c6665c9e2064e666e229 |
|
BLAKE2b-256 | 35d8e90985ce9a2e157dffe060fe7090494d3e388b2e4493f6278c096ad0c9cc |
File details
Details for the file aiohttp-3.2.1-cp36-cp36m-macosx_10_11_x86_64.whl
.
File metadata
- Download URL: aiohttp-3.2.1-cp36-cp36m-macosx_10_11_x86_64.whl
- Upload date:
- Size: 430.2 kB
- Tags: CPython 3.6m, macOS 10.11+ x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | defc2afb61b9fd08b2d07e536a1497a50925f1078e598ebc7eba080d33cdd5f6 |
|
MD5 | 4eb11d44efdee910aa42bef0a097c148 |
|
BLAKE2b-256 | 1826d1fbcd1cc40094485f8066c7013590e20d0863e8f39b1af53d48fccaddc9 |
File details
Details for the file aiohttp-3.2.1-cp36-cp36m-macosx_10_10_x86_64.whl
.
File metadata
- Download URL: aiohttp-3.2.1-cp36-cp36m-macosx_10_10_x86_64.whl
- Upload date:
- Size: 432.1 kB
- Tags: CPython 3.6m, macOS 10.10+ x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0be9782f27f150acc18c20ddb035655625d054ead119eb6e906647eb9a94f6c4 |
|
MD5 | d016df83f02000829478d3e4160e8b3f |
|
BLAKE2b-256 | 9262dc422233c50b42c05b0ae68756c5015f3e8ce6b4df6f7e3bced5e94858dc |
File details
Details for the file aiohttp-3.2.1-cp35-cp35m-win_amd64.whl
.
File metadata
- Download URL: aiohttp-3.2.1-cp35-cp35m-win_amd64.whl
- Upload date:
- Size: 418.0 kB
- Tags: CPython 3.5m, Windows x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd2092d2c2cfdd3363e3815d473464b45c79e0794d60e7c4c89c2adc12ef64b4 |
|
MD5 | 59fb1c7d0d920380c788a99244321d3e |
|
BLAKE2b-256 | 09aa65f033caa231d96d8a4e2f849a9f4217d4885f689863ad4f3a7139e2c457 |
File details
Details for the file aiohttp-3.2.1-cp35-cp35m-win32.whl
.
File metadata
- Download URL: aiohttp-3.2.1-cp35-cp35m-win32.whl
- Upload date:
- Size: 404.3 kB
- Tags: CPython 3.5m, Windows x86
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 294cf24187b8bcf3e9b368f2d67e1a6584b0a27667886612eff02d0cd3be460f |
|
MD5 | f72f9b8bcc93df57f6d46200ef1c6dea |
|
BLAKE2b-256 | bd0e0682174da40326578f804b848a017f8337f54e9d98fa49a42039ca26b4d6 |
File details
Details for the file aiohttp-3.2.1-cp35-cp35m-manylinux1_x86_64.whl
.
File metadata
- Download URL: aiohttp-3.2.1-cp35-cp35m-manylinux1_x86_64.whl
- Upload date:
- Size: 745.9 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a169c6d5173c7f60e70055a2ab71b93c90f2d693164e93502744b82ff7c0e282 |
|
MD5 | e798f1d4173d9477560cf1da05e58f11 |
|
BLAKE2b-256 | 15e34a6c7eb7b2be7ff906c45cabf19e3b08dd64e89f2940669f4b4af25434fd |
File details
Details for the file aiohttp-3.2.1-cp35-cp35m-manylinux1_i686.whl
.
File metadata
- Download URL: aiohttp-3.2.1-cp35-cp35m-manylinux1_i686.whl
- Upload date:
- Size: 720.3 kB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d62305fca4479b7f0a1254a78fa1e57e0440f5e9547a1d47e5f8dece264d414 |
|
MD5 | b5ac1548d9eb7b157c8ce31d3ef94fb3 |
|
BLAKE2b-256 | 601e2d8bee63a4b5dab578ddb351e86ad8467baff9a1f6f874a7c63ac8e94bd3 |
File details
Details for the file aiohttp-3.2.1-cp35-cp35m-macosx_10_12_x86_64.whl
.
File metadata
- Download URL: aiohttp-3.2.1-cp35-cp35m-macosx_10_12_x86_64.whl
- Upload date:
- Size: 420.9 kB
- Tags: CPython 3.5m, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29cbcdf61b094140a10923ededcda6c961032d44518d64fc832cb602a5ff21e8 |
|
MD5 | da01c25f53d49ea4a0ff7a05fe74d4fe |
|
BLAKE2b-256 | 57aee63d90736b478130715fca4a84b39f5615c103d5146699413558d225dac9 |
File details
Details for the file aiohttp-3.2.1-cp35-cp35m-macosx_10_11_x86_64.whl
.
File metadata
- Download URL: aiohttp-3.2.1-cp35-cp35m-macosx_10_11_x86_64.whl
- Upload date:
- Size: 427.7 kB
- Tags: CPython 3.5m, macOS 10.11+ x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a00d4115ae2f5dcf678f482e2235d89eea495e883297e5fd19db429aa1e64d43 |
|
MD5 | be086b19dcef8169460fff441f156f9d |
|
BLAKE2b-256 | 5f86f876c9050bc3c4785700735627d7a5e83ecb9e1667bdaf106516f90830dd |
File details
Details for the file aiohttp-3.2.1-cp35-cp35m-macosx_10_10_x86_64.whl
.
File metadata
- Download URL: aiohttp-3.2.1-cp35-cp35m-macosx_10_10_x86_64.whl
- Upload date:
- Size: 429.5 kB
- Tags: CPython 3.5m, macOS 10.10+ x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43930d119cae96b1a743c2e542fe93bd8db48d8b0d041933bd0b008a29f286f2 |
|
MD5 | 96aec35cb28bdeb63b07655b941aa6d0 |
|
BLAKE2b-256 | 2a6e60c003bae2fef15124611a3b82f67e954844154147d7c5d3b2a7ec46da16 |