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.4.3 (2018-09-04)
Add app.pre_frozen state to properly handle startup signals in sub-applications. (#3237)
3.4.2 (2018-09-01)
Fix iter_chunks type annotation (#3230)
3.4.1 (2018-08-28)
3.4.0 (2018-08-25)
Features
Add type hints (#3049)
Add raise_for_status request parameter (#3073)
Add type hints to HTTP client (#3092)
Minor server optimizations (#3095)
Preserve the cause when HTTPException is raised from another exception. (#3096)
Add close_boundary option in MultipartWriter.write method. Support streaming (#3104)
Added a remove_slash option to the normalize_path_middleware factory. (#3173)
The class AbstractRouteDef is importable from aiohttp.web. (#3183)
Bugfixes
Prevent double closing when client connection is released before the last data_received() callback. (#3031)
Make redirect with normalize_path_middleware work when using url encoded paths. (#3051)
Postpone web task creation to connection establishment. (#3052)
Fix sock_read timeout. (#3053)
When using a server-request body as the data= argument of a client request, iterate over the content with readany instead of readline to avoid Line too long errors. (#3054)
fix UrlDispatcher has no attribute add_options, add web.options (#3062)
correct filename in content-disposition with multipart body (#3064)
Many HTTP proxies has buggy keepalive support. Let’s not reuse connection but close it after processing every response. (#3070)
raise 413 “Payload Too Large” rather than raising ValueError in request.post() Add helpful debug message to 413 responses (#3087)
Fix StreamResponse equality, now that they are MutableMapping objects. (#3100)
Fix server request objects comparison (#3116)
Do not hang on 206 Partial Content response with Content-Encoding: gzip (#3123)
Fix timeout precondition checkers (#3145)
Improved Documentation
Add a new FAQ entry that clarifies that you should not reuse response objects in middleware functions. (#3020)
Add FAQ section “Why is creating a ClientSession outside of an event loop dangerous?” (#3072)
Fix link to Rambler (#3115)
Fix TCPSite documentation on the Server Reference page. (#3146)
Fix documentation build configuration file for Windows. (#3147)
Remove no longer existing lingering_timeout parameter of Application.make_handler from documentation. (#3151)
Mention that app.make_handler is deprecated, recommend to use runners API instead. (#3157)
Deprecations and Removals
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.4.3.tar.gz
.
File metadata
- Download URL: aiohttp-3.4.3.tar.gz
- Upload date:
- Size: 822.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab53f89c3b027a9c95f02bb57e96292ed87c8bcf7e5441720ead621c8a53096c |
|
MD5 | cce4893e1b774034d85507e9618e9761 |
|
BLAKE2b-256 | fe0a46eec879f11a922d99dde03d2563b7afc57d4b826957d591853078ad494c |
File details
Details for the file aiohttp-3.4.3-cp37-cp37m-win_amd64.whl
.
File metadata
- Download URL: aiohttp-3.4.3-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 576.9 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 378e95c84083c1eda52e07f0f041715eae9290629f6f57092982fcf4b1e6ab86 |
|
MD5 | 3161ced2438789a91831cc5fb41ec90e |
|
BLAKE2b-256 | 3bdffa3cc2bc2c57d696dd6df5684b5ca740de3ae221059246281ff69b17d346 |
File details
Details for the file aiohttp-3.4.3-cp37-cp37m-win32.whl
.
File metadata
- Download URL: aiohttp-3.4.3-cp37-cp37m-win32.whl
- Upload date:
- Size: 550.8 kB
- Tags: CPython 3.7m, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38ad514e1908aec6b5489f276fbbd989c1210a4598c2ccf967e1bdb0785752da |
|
MD5 | 958b97452b4ffd2a60700a32aa049acd |
|
BLAKE2b-256 | 706b4e12343f493e8ce8ecb736a2b56b7493ddc763cd94c49d60d1ff6762cacd |
File details
Details for the file aiohttp-3.4.3-cp37-cp37m-manylinux1_x86_64.whl
.
File metadata
- Download URL: aiohttp-3.4.3-cp37-cp37m-manylinux1_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f7183b87f99ae72f9a901f0c128c88115565d18bbd1ec02db9238cda4f7a5e8 |
|
MD5 | 40bd14fb9be27b526fb532ad9c8eddfe |
|
BLAKE2b-256 | 7ba00b8d796decff2d6475de8994ffe07d50cda3085d9d24bd3d25669c967471 |
File details
Details for the file aiohttp-3.4.3-cp37-cp37m-manylinux1_i686.whl
.
File metadata
- Download URL: aiohttp-3.4.3-cp37-cp37m-manylinux1_i686.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 632f9805994e51a056b9f73c8418d97cd3fbfdc01a13e0037d97f681b962fe58 |
|
MD5 | c211ab4422ec0bef9e873947f5cfccd3 |
|
BLAKE2b-256 | 7c533e517b591b0d5850f24685bdbdb3757d3606a414cc37613d6024197422c5 |
File details
Details for the file aiohttp-3.4.3-cp37-cp37m-macosx_10_13_x86_64.whl
.
File metadata
- Download URL: aiohttp-3.4.3-cp37-cp37m-macosx_10_13_x86_64.whl
- Upload date:
- Size: 590.6 kB
- Tags: CPython 3.7m, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9dbe2fabfcd5f64723ff1529dd6d6ce284e9e41f6ce001db271d0620c2ca592 |
|
MD5 | 885670c638f5cda40ed0bd8e6d8de6e9 |
|
BLAKE2b-256 | 36d682fb264acc491309a3765d2da1837fa2084b02dcebc16af527d9643188ff |
File details
Details for the file aiohttp-3.4.3-cp37-cp37m-macosx_10_11_x86_64.whl
.
File metadata
- Download URL: aiohttp-3.4.3-cp37-cp37m-macosx_10_11_x86_64.whl
- Upload date:
- Size: 599.2 kB
- Tags: CPython 3.7m, macOS 10.11+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf78fb3b1eef64f857bc22662dcd326712618f89fb67bb96455be1e8f4a3c5e8 |
|
MD5 | 42b069a1313f8737dae3a2ca0df4e4ea |
|
BLAKE2b-256 | 7cfa88a36ebef9daf927aa045f1a6fbea68c8c967d614e2eeb8a520a74ecf071 |
File details
Details for the file aiohttp-3.4.3-cp37-cp37m-macosx_10_10_x86_64.whl
.
File metadata
- Download URL: aiohttp-3.4.3-cp37-cp37m-macosx_10_10_x86_64.whl
- Upload date:
- Size: 602.6 kB
- Tags: CPython 3.7m, macOS 10.10+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 974b0ede55cb936e1616a5c9271265f9973f23fb1db56ac1a41b2d3f4eec6ecb |
|
MD5 | aeb50631d2fa3a2594d10263e3688a1f |
|
BLAKE2b-256 | 8d3e429da7dfae29ae5f9b71be59e2f8c6762353bf6b97b4fef1eb4121ed3c77 |
File details
Details for the file aiohttp-3.4.3-cp36-cp36m-win_amd64.whl
.
File metadata
- Download URL: aiohttp-3.4.3-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 577.0 kB
- Tags: CPython 3.6m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20518b0c885b114041b6a59baf7c9da2e28d7131b1930e41cc2da14ce4756223 |
|
MD5 | 5907d74ae67d49e68f144db6f36c1538 |
|
BLAKE2b-256 | 89935b2a2e7ae29d38ae0a2a6d689275f182e78389be4174b43fdb80e13a6cef |
File details
Details for the file aiohttp-3.4.3-cp36-cp36m-win32.whl
.
File metadata
- Download URL: aiohttp-3.4.3-cp36-cp36m-win32.whl
- Upload date:
- Size: 551.2 kB
- Tags: CPython 3.6m, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b5316c922ed43e96574aed94ccf45c41325e06892e12ac5ac11bec4d6341ebf |
|
MD5 | eeb0cd9e22a0a62498190436ddb93362 |
|
BLAKE2b-256 | ae88c849b3c149775ffbcf42e2cf9de8e46d00a4b92fb7edf4894ccd23187419 |
File details
Details for the file aiohttp-3.4.3-cp36-cp36m-manylinux1_x86_64.whl
.
File metadata
- Download URL: aiohttp-3.4.3-cp36-cp36m-manylinux1_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 973c0c07a2b1d76152ac8603ba7cdd358d4e6485149ad09d264425a10ad24d76 |
|
MD5 | 62134df780bd86af0320db4b63209903 |
|
BLAKE2b-256 | f95b4ff6593f812f1c3348dbc8a7fa5c5f2f1443a5c0b84a98c0f83b6a53fa20 |
File details
Details for the file aiohttp-3.4.3-cp36-cp36m-manylinux1_i686.whl
.
File metadata
- Download URL: aiohttp-3.4.3-cp36-cp36m-manylinux1_i686.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95bd80e9850d8adbe25f60423bcd1b5e3df7f3bf04eb1265b11118d6bf8c6b80 |
|
MD5 | 25b1b39f5d5ba9b6a9770606bb411f07 |
|
BLAKE2b-256 | ab769ac03a1c5de2cd13fd3c18bcce8ab028214b4bb97d4144a6b163ac48cca6 |
File details
Details for the file aiohttp-3.4.3-cp36-cp36m-macosx_10_13_x86_64.whl
.
File metadata
- Download URL: aiohttp-3.4.3-cp36-cp36m-macosx_10_13_x86_64.whl
- Upload date:
- Size: 594.0 kB
- Tags: CPython 3.6m, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6dfe2771b35ff3c935f84657cc6a060d1d9b63c47a21031cabdc8579d89eaa61 |
|
MD5 | 1c5ddbcf220da783670f03a882857290 |
|
BLAKE2b-256 | af1efa17e61ab1abd612355ab26f461ab53730076ba6408b594feb84bdadc394 |
File details
Details for the file aiohttp-3.4.3-cp36-cp36m-macosx_10_11_x86_64.whl
.
File metadata
- Download URL: aiohttp-3.4.3-cp36-cp36m-macosx_10_11_x86_64.whl
- Upload date:
- Size: 599.3 kB
- Tags: CPython 3.6m, macOS 10.11+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d058dd2d77a8d10d076f92781e6431d93bf0a14bc27ec04416bf7c723f74ba7d |
|
MD5 | 68f50a410639b14b75e4f1873e7c51a1 |
|
BLAKE2b-256 | 4499228eb5555256f01b7536d87315c8d40e52887567541446cad437892526f9 |
File details
Details for the file aiohttp-3.4.3-cp35-cp35m-win_amd64.whl
.
File metadata
- Download URL: aiohttp-3.4.3-cp35-cp35m-win_amd64.whl
- Upload date:
- Size: 575.1 kB
- Tags: CPython 3.5m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9fc5afe9eb50eeba32d1a44437d6da050be41756b4a12b72a11d794a86d82944 |
|
MD5 | 6a310484597607a46b5a90baa886acea |
|
BLAKE2b-256 | c9c4c679eb6354b50953cf198f469e1f195ebd598cd3321bc3a921eaa2900b0e |
File details
Details for the file aiohttp-3.4.3-cp35-cp35m-win32.whl
.
File metadata
- Download URL: aiohttp-3.4.3-cp35-cp35m-win32.whl
- Upload date:
- Size: 549.3 kB
- Tags: CPython 3.5m, Windows x86
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68f57c5af7a48c6b19acab06ebc07305f2f14b3e70a73d8ef6e8169d4f5d1e5f |
|
MD5 | 8e1208a65d9955d32ba330ae2622f746 |
|
BLAKE2b-256 | 5b7db6cfde4995445076e4c189488c94c9ba96e204da2cc18b047386f068f4c8 |
File details
Details for the file aiohttp-3.4.3-cp35-cp35m-manylinux1_x86_64.whl
.
File metadata
- Download URL: aiohttp-3.4.3-cp35-cp35m-manylinux1_x86_64.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f660a672ed11dbd0181b9cf4b40ef4d6c45d3703acf20d69d375a702ca7a631 |
|
MD5 | e0ba17a8db7eb3df7e6a08e62db7b7e2 |
|
BLAKE2b-256 | 7e80a68ebbaad3aa864010cb37f6390f1f2f64c2291e932c806c22ce5b118f00 |
File details
Details for the file aiohttp-3.4.3-cp35-cp35m-manylinux1_i686.whl
.
File metadata
- Download URL: aiohttp-3.4.3-cp35-cp35m-manylinux1_i686.whl
- Upload date:
- Size: 1.1 MB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eef7561e7e45a0789554f84a6d6568cdc6c197ccc25b1a9b2b57ae609e237a37 |
|
MD5 | a9015e264ee0c9c4e94dd508766b1e8e |
|
BLAKE2b-256 | d662ff650c86d1e2b8868d3d38f0d2530199a11afe5692c3637e9dd0cdc2d9b0 |
File details
Details for the file aiohttp-3.4.3-cp35-cp35m-macosx_10_13_x86_64.whl
.
File metadata
- Download URL: aiohttp-3.4.3-cp35-cp35m-macosx_10_13_x86_64.whl
- Upload date:
- Size: 588.1 kB
- Tags: CPython 3.5m, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0ecd9da4a6e6920381896ddbbb7ebebaf542e53a9b347334842a370a9598bec |
|
MD5 | 4c28d38b7861548951df5cfcac0ff91a |
|
BLAKE2b-256 | f25c93824b403bcd8da1332fc197ba8a73677ca06cc62d98cd272b68753770f6 |
File details
Details for the file aiohttp-3.4.3-cp35-cp35m-macosx_10_11_x86_64.whl
.
File metadata
- Download URL: aiohttp-3.4.3-cp35-cp35m-macosx_10_11_x86_64.whl
- Upload date:
- Size: 596.5 kB
- Tags: CPython 3.5m, macOS 10.11+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.5.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce84aadbd9c0e738b1190b6c07149b3005b7666ec21c9f912b18e894c08b467e |
|
MD5 | e041b5b4b79cef050453151596e8a50e |
|
BLAKE2b-256 | c2272199968361f6e206be64750cdf98ee255341df0e5dcc4aed5d3744de86c0 |