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.3.2 (2018-06-12)
3.3.1 (2018-06-05)
3.3.0 (2018-06-01)
Features
Raise ConnectionResetError instead of CancelledError on trying to write to a closed stream. (#2499)
Implement ClientTimeout class and support socket read timeout. (#2768)
Enable logging when aiohttp.web is used as a program (#2956)
Add canonical property to resources (#2968)
Forbid reading response BODY after release (#2983)
Implement base protocol class to avoid a dependency from internal asyncio.streams.FlowControlMixin (#2986)
Cythonize @helpers.reify, 5% boost on macro benchmark (#2995)
Optimize HTTP parser (#3015)
Implement runner.addresses property. (#3036)
Use bytearray instead of a list of bytes in websocket reader. It improves websocket message reading a little. (#3039)
Remove heartbeat on closing connection on keepalive timeout. The used hack violates HTTP protocol. (#3041)
Limit websocket message size on reading to 4 MB by default. (#3045)
Bugfixes
Improved Documentation
Deprecations and Removals
Deprecate custom application’s router. (#3021)
Misc
#3008, #3011
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
Hashes for aiohttp-3.4.0b1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4899330690961f690d90c5ebbcc3ed9a8569615a23f6dc593e3a32deb5dec7b5 |
|
MD5 | ccb48d04c4320e1697b6ccbeee371afe |
|
BLAKE2b-256 | 5bceebc5c973b88663cefc7898092ebdb241f023628200ad3eccedc62db48a6c |
Hashes for aiohttp-3.4.0b1-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a3c805cf4bb55299053207272471ff0d963df9c51a69a3d2299ac16c47fae5a |
|
MD5 | e6f158df626a1be7c97d64c9e6d0e0eb |
|
BLAKE2b-256 | c36fb2a6914be81d9fff714138768317e86a0fba1e69fc9b1b7fca84c8ea5286 |
Hashes for aiohttp-3.4.0b1-cp37-cp37m-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5077e3c15e41f928e3dd850b8f3ec67e6e0a13e2dd5dd8bc2a30ac7571036e24 |
|
MD5 | f28b5c6bfd8325284a21d4f861910d34 |
|
BLAKE2b-256 | 808d202a77583d9bf61bec1e24d73581ce07d095d0b6ead1824a6dc6ea247b82 |
Hashes for aiohttp-3.4.0b1-cp37-cp37m-macosx_10_11_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5d4d313ebd2d4b4e916d5ced35c0dc4de9155d6a2f36faf5098379a7a7a37be |
|
MD5 | 00551d49ccdaf2d005cf28cddaeb4157 |
|
BLAKE2b-256 | 88190b34894a30784a38336040da2b63524dd2f8d1d31b999d6d2cdb66edb236 |
Hashes for aiohttp-3.4.0b1-cp37-cp37m-macosx_10_10_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aaa521a80d09f9aa3031bb11b70818e46ecb0bf994fd9ac4634f6300b91903d4 |
|
MD5 | 34bd9f40cbdc9c9d04c05053008c6dfb |
|
BLAKE2b-256 | b5ed9a877cee416854851ffec2a02fc6eae352a1ba7b1fd425228606e3c524f6 |
Hashes for aiohttp-3.4.0b1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf2b475a16494abc21d44a7a7dba428d25ea8a6e69d0772466870280729a0c4a |
|
MD5 | 70575bd9261ffe7b8d2e582b4e67bae1 |
|
BLAKE2b-256 | 0267cc7b07a70cd67da14d7aeb91606da4e0cbf9a87c484549542a3a1c30270a |
Hashes for aiohttp-3.4.0b1-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c03d5b111ad3d18254680015f5cf885efb43bd5984678d8b6ece3f9dbb38c248 |
|
MD5 | f18d0cc6e04e6457fb8c8bfb83bc5092 |
|
BLAKE2b-256 | 832ff23026727433e06ba1f88e5f8cb60d125b45100e7db25f75c3fa80c89f79 |
Hashes for aiohttp-3.4.0b1-cp36-cp36m-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82f0dd3affe053bb89fcdb24120f72bf284d1d9f1bf2d169e0cf98321855d676 |
|
MD5 | 07cbdbf1d7b9635b886fc9f96ced096c |
|
BLAKE2b-256 | 2c95a60ed6b65decd2ca0a057dc73e7aa34c2592f3306bcd3fb608342fd862a6 |
Hashes for aiohttp-3.4.0b1-cp36-cp36m-macosx_10_11_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96119c9fc5ed7fbccfb28496c00357f14d052b73e75a621f31e93a85350c89a8 |
|
MD5 | 2327abda7744dedeee78d47667e16772 |
|
BLAKE2b-256 | 54784a369d147f5013246f35b0385a4f2c49bfcbe3a1c3dc2148b9067646baf5 |
Hashes for aiohttp-3.4.0b1-cp36-cp36m-macosx_10_10_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb80821965e99e437ae001cd68d4b962a8043edc6c3c27dd330f489b1087813b |
|
MD5 | 6e5624ee9d7f7f1f4a6c7ab7c3cb12ab |
|
BLAKE2b-256 | ece6c5d97865378f6318f2b6bf4f9d0c238ea5a9015d8da2cbf16d9039e20ae5 |
Hashes for aiohttp-3.4.0b1-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f697b952490d5bb57eea230e9c4f526232b5c90dac65f17b5586674ffca33de |
|
MD5 | 039457049b7b078cde38e65df4cd15b6 |
|
BLAKE2b-256 | e42be4408b7161f41c324056653374a51731a8de794ec933b8bcba6005c9d7a3 |
Hashes for aiohttp-3.4.0b1-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d1334c35af34a8bb9319acf387f5fa4ae5913106f7e732548ceb1f0f085b590 |
|
MD5 | d9ce278d50aad1a8d54c058d1e2aae00 |
|
BLAKE2b-256 | a7dca6084c881bc58ee04f05cafedc740c45536fbaa1eb4a032b2be20a69e6b8 |
Hashes for aiohttp-3.4.0b1-cp35-cp35m-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d34111c32069ec2ee7f97826f7d4865c80a52821594961701f45004392e03b61 |
|
MD5 | 8beaccd988450cfd2c926d0d63eed3b1 |
|
BLAKE2b-256 | ae0d7e2eaed304557d595c02c1ee4533d22bb3bcbfe280d732cbad6b5e61dd2a |
Hashes for aiohttp-3.4.0b1-cp35-cp35m-macosx_10_11_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79a71afddd9fce3c70fcaf3e6bce27b865821a59506bc1ef9c08f70ddcf62b1b |
|
MD5 | 0cccc2d11f01bc65efacf20b3a30baf5 |
|
BLAKE2b-256 | fded0db12b5b2edb1e155322816558fa08ae6655bcf8c5758a24e5af8939169b |
Hashes for aiohttp-3.4.0b1-cp35-cp35m-macosx_10_10_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67250f5d5221a518607e6f19327d6dd86108dafd95503143a4af0bafcc84c708 |
|
MD5 | 29561097ef1411c361f1880e386f2937 |
|
BLAKE2b-256 | 6027f03783e6a6ab135a17f8f7ef95c51e0f70c975a0058271c51e31d211564f |