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.0b2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 697889c0e14e69f6e4428f180bb3f42f84aa6e026e9f65b8471f3d9ccb3800d7 |
|
MD5 | 8480111581c00c43090dec998b3e59c4 |
|
BLAKE2b-256 | 28d2c55acab30c941a9fc94fe56f50d2886ed0ed381ab7be70e999a97495eeb1 |
Hashes for aiohttp-3.4.0b2-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9ac0d48414586175110aa7778d602680e0d97d0e53fd78b7db23c0ceeafa00a |
|
MD5 | b2d21ad8718320564ab4488458521375 |
|
BLAKE2b-256 | 38fe8f27d44e84afe289802629c7c86061ba8dca4d9a69a3e7870c89f916f582 |
Hashes for aiohttp-3.4.0b2-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b87d3ad5936beeab7af5c1899a2c90bbe5fbe2e780adc9d056adcd19bf656ab |
|
MD5 | 0d4143f442d3309c2aca20c7fcf6708b |
|
BLAKE2b-256 | ba22a5d095c6b1114e0a64da0bf85634ff80f823f4fc5a3690cc517152fe9151 |
Hashes for aiohttp-3.4.0b2-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24b47285d13e49fa8b16d59cac0bcf852918dbdd257cf3ebe4b06f244a8b56e6 |
|
MD5 | 25307cc8f094522fc8bd7a2625e0df21 |
|
BLAKE2b-256 | b529f215e861b661efabf8a70cd9bf1cea01656857cdcfbb49bc52a03a925393 |
Hashes for aiohttp-3.4.0b2-cp37-cp37m-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90c2b1dda84da51f678909b5d8412f937d652e46f6b3515fdcae43ae8afdacb0 |
|
MD5 | 6eb6bfdc1cc9b3435eba774e16272b8d |
|
BLAKE2b-256 | c23646d2dde5c6d6ec28b2c987f88279f2ebd1104e4f39a854a849cbeda3b8ae |
Hashes for aiohttp-3.4.0b2-cp37-cp37m-macosx_10_11_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4f8a4c69314f74ac7e6ec1f0a98d1f793acc8d9e48d14c8b2ca6cf9b70ff4d1 |
|
MD5 | d0efde8dc2b0ef68955b7a35aaeafc6b |
|
BLAKE2b-256 | 42b39a1bab945c6cd3c2f604fe1ad81f183e33cdadc8600771969b1f0811129e |
Hashes for aiohttp-3.4.0b2-cp37-cp37m-macosx_10_10_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e3993cd6fd05cf0dcba2d913a4d1e02cd7db8d893e7ac34669ca4583b5a01ba |
|
MD5 | 5f5fa343e77c437d10e3a7f1f554952c |
|
BLAKE2b-256 | 138b9142960026728e9a11824bcd74c429251f032314b835606f9f07372db68b |
Hashes for aiohttp-3.4.0b2-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f51d13962866007d7b8fe84d69439f82250f4f3cc22888e45a803b43e81512a |
|
MD5 | 4ffe792b1bf30522162748b228646749 |
|
BLAKE2b-256 | 12e9ca4c0e1e4172c6f88e49d156605db98e314ef7e354b97381840e55a3548a |
Hashes for aiohttp-3.4.0b2-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a86a4058da5962031fa56e7dff52884c19029e00434cfb1ed170faace96d2337 |
|
MD5 | 2f864fadb88e03d9a566e47289c92bcd |
|
BLAKE2b-256 | 035cdc33833512f013e594bc4f5465287de9e48abe35175cc61d7b7b97c76c6a |
Hashes for aiohttp-3.4.0b2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc16bf0a2958533046997c0a6468b837322b383f2ab20269cfd5885d764f83a0 |
|
MD5 | dfa27148346d109fef970130809dddf6 |
|
BLAKE2b-256 | ee0fbb80f570b2ac93da4eaa070d6f989df2e09c45fc838abbd32b3ae06c3187 |
Hashes for aiohttp-3.4.0b2-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccd5150af498f0ca1278707574ce400ce316a61711891fe9a6d37c77d972911b |
|
MD5 | c27f5c8b23dd572cc2debf38f6095b43 |
|
BLAKE2b-256 | d1f0bd2644738b7328c5fba56e4efa9a3c6fdf0198adcdc406fdf619af89b846 |
Hashes for aiohttp-3.4.0b2-cp36-cp36m-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50a5427d9ee91e1eb3d86518e78158ce08a5a33a1a3e213886b77750dd14545c |
|
MD5 | ccd006a03ca55c2ea747ff3b31f6076b |
|
BLAKE2b-256 | 683af2e8b5c00a0f4c86743912ffabfffd065b498dd35850be0c6ceb0b8a7c90 |
Hashes for aiohttp-3.4.0b2-cp36-cp36m-macosx_10_11_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b18a33ff0479a717e4e1948b522b362dd6b541b9cae6bec5d27681e643e12ee6 |
|
MD5 | fd8e889ae9ff1d0b4f4cd7c6276fe8bb |
|
BLAKE2b-256 | 77b23934412c36ba1901dd35d2c844864fd5f6317b545c4158531d966fb8e52d |
Hashes for aiohttp-3.4.0b2-cp36-cp36m-macosx_10_10_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64cfde76c15561207aec55adeb7118ead3cb98ae26fe5d86f339b45e0e34dba7 |
|
MD5 | a2c5c9e778dc1db8e30283edca47bcfd |
|
BLAKE2b-256 | deb9d37ae912dd59f9727180896b450c3a94a3d3a391d382c51d4d893e5f451a |
Hashes for aiohttp-3.4.0b2-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7cce4282a1b564e00716cd55450fc5023c427671c0e0733bbd0fa5abdaf72439 |
|
MD5 | 42844404cf1bc54d73ae77d4f0c663d2 |
|
BLAKE2b-256 | ec3f32b561509cb0cd160beb1cce87d0405de94122ec3f7d13adcffe9d54e341 |
Hashes for aiohttp-3.4.0b2-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b6dc33411fea19a919131140383312cc7689e223407c20534b27c3e10641eed |
|
MD5 | 0badc931f2fdc5af74028cde5ea3de2f |
|
BLAKE2b-256 | ee820f1f5e57c01de5b9653f5e6d92dfcd1b701c9abda2a16eedc2c1c52cc859 |
Hashes for aiohttp-3.4.0b2-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e90684008292c32df27d2de390f02ce3687654207d636bf0d5b51d2a1bfc255 |
|
MD5 | b83e18721d06606c91eb63503fc88efb |
|
BLAKE2b-256 | 5f940e6469967b1ccb71090303f43db209937afc0ebc2ac895dee584946b2249 |
Hashes for aiohttp-3.4.0b2-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f7b871343b9a46b4d9f1d45a81f9bbd9e0349fee5d35ee8b9900134cd48a887 |
|
MD5 | e55a848802e03198600ebe52c60608c8 |
|
BLAKE2b-256 | a6cd898421c82f2bc5f0d95bd6d248fa57f18c91f8ffc248f4c3ca50514bd343 |
Hashes for aiohttp-3.4.0b2-cp35-cp35m-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a09f4c2284feaed5564cf43cc118db21b3911067dfc98f667585c89cbf4f56c |
|
MD5 | a2b2d3c8734784a1c91e11b39aa97bd4 |
|
BLAKE2b-256 | 8da9fc61494d07442dc30349875b0c4e4b027f83a1b111ccc660d919a8e8084a |
Hashes for aiohttp-3.4.0b2-cp35-cp35m-macosx_10_11_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2293ac43188e757d9bf03f2161733d193b126bad837adac8399b0330fd4e53e5 |
|
MD5 | e8504e0ccc22953e3df9056637297b1c |
|
BLAKE2b-256 | 8ce0228b602ff11cc17467c3ce3e16a858ea301230b4f983684be78455713beb |
Hashes for aiohttp-3.4.0b2-cp35-cp35m-macosx_10_10_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f61222b4d60d5a5204622a02b92166c8af3eec48377b3b72a3df147acb2f5ebd |
|
MD5 | 99cfdb7d7594a505467811bae017456b |
|
BLAKE2b-256 | 0efec50122cfe977a63a378a4e1ae0fcfb8cd2df64fdcf2e1f169e4c557babd8 |