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.0a0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c650bc43e371bb9df8a61a64b84c0c17b6af81addb54c246f01eba3826178b2 |
|
MD5 | 1b94a8fc629b5e3152ac98c8194e9d50 |
|
BLAKE2b-256 | 67a281ce6bd3519517d95f20e2962b0d01e908d4892ea25df8ee03b9299857cb |
Hashes for aiohttp-3.4.0a0-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 866afe4be97cf196c702d52cbcc4226ff503d78e922c5a04a8d64d447978dec1 |
|
MD5 | 5d4aae2fcd11228b3fff8ecb678e27c7 |
|
BLAKE2b-256 | 5bd26f96933e9f983ff7794e5220d9d658268ada7e958d0046beac72b36dfd19 |
Hashes for aiohttp-3.4.0a0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab2859e0f41ab1e2c63a6c9ff564b588dae2ff297f1dfcce045ea7b7287707cb |
|
MD5 | f00c80656f17982ee0d179181883ba82 |
|
BLAKE2b-256 | eba8aa3f1b2496c157951dceeab4a2e0ecec8d9f3b8b73305dba5e5e612f2d94 |
Hashes for aiohttp-3.4.0a0-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14c07f3de64df4307f8247397a24e8c4f1dc22f50452857409d58f9757faf4c1 |
|
MD5 | 0c5864591a3d082b090f9d12da0f6d20 |
|
BLAKE2b-256 | b1bf53189147c3abaac6b6418d94df0dfde4fe2f2050e9a6484dda2f2f4ff26c |
Hashes for aiohttp-3.4.0a0-cp37-cp37m-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 636f89e534cd68a9e223927506dd3e839410ae20f357dd3680b384f5a537f7e3 |
|
MD5 | aef4943e514446c772d8ccfae6fae9b6 |
|
BLAKE2b-256 | 71d4c84568feb90025a2df0abb70f3aad02bebb7457f517c7f298e7ebc2c19b0 |
Hashes for aiohttp-3.4.0a0-cp37-cp37m-macosx_10_11_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92c19a5e609bd24a6451d614676e37c2e38968ec9df69d10b482e70d61ea486f |
|
MD5 | 2eea4f0e289b529ab479cef2523d0216 |
|
BLAKE2b-256 | 4638459d8f73b70e83548258b763d2f902a84485fb22f0292eb88f75f7d51cd1 |
Hashes for aiohttp-3.4.0a0-cp37-cp37m-macosx_10_10_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db77132460ef34e96cdd20129424d4f953dc06568fd2ebb474c9000e5443e8d2 |
|
MD5 | 988b1babea7fb7b02d4b6e6bb430fe1c |
|
BLAKE2b-256 | 539dbac89b34ddc040b02d579f7e141d55478f166a04d233f1731a73f5c5cbf0 |
Hashes for aiohttp-3.4.0a0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b182c0f1e30cd57a2d3e554c923fae6024535bd982a6d71fc2512efe4b9d1b2 |
|
MD5 | aae04b534b99684b8a24c8c3148dec88 |
|
BLAKE2b-256 | f3c0de3f6422464c0f037cae57d0bd2d55329363c26612d636acf3bb3743b8c3 |
Hashes for aiohttp-3.4.0a0-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff69734e2b8e2b81a3a8cf2bee38b3eef0c370399e209812f8e1e590b4ba234a |
|
MD5 | cce218cea1e70543d0a8b1ee7e246643 |
|
BLAKE2b-256 | 57bc0ef5c15d6950405480469d470a8c5508d67f7e50e7aaa1f0a052dbdcda45 |
Hashes for aiohttp-3.4.0a0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c599c7df78b776e1796beb106c4f2370e5e29f67cdc507256424ee015df29216 |
|
MD5 | 8ba1fc4a44134147ed26e1f106811df1 |
|
BLAKE2b-256 | 1df79f71eb91d97ddb048ff436ccd4687e10d8a61e7b3ca247b034ee2f7407a0 |
Hashes for aiohttp-3.4.0a0-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39af9e3f9f805b187473a8b936a5616576d753358f2a223ff0990fe974cf72b1 |
|
MD5 | 0b15934c7c703cf1e1c10a451e6f4bca |
|
BLAKE2b-256 | 2a35ea327a47d96bced48797f19787aeb671ff9758112be5eae2282d9b204254 |
Hashes for aiohttp-3.4.0a0-cp36-cp36m-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f20df358f4994482a2c47cb8a523a130bdf5598e5759167032029b94c45bcf27 |
|
MD5 | 8bf6c768179c5d7af77d9a042a481b30 |
|
BLAKE2b-256 | af7b0c5a9fe718f52215b2b49aaf1dee4e5f62a4b6f89c4671e9692c036826b1 |
Hashes for aiohttp-3.4.0a0-cp36-cp36m-macosx_10_11_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 308dbf8c562526ee6654acd190561fcce5d7724abd25219e6c0bdca75c875fc4 |
|
MD5 | 871ab4a4a8002b6b557c20ab62557a89 |
|
BLAKE2b-256 | 43a10c80fde6ec65904959ceae085675b05f758b19cc42abf45c04f31b04bea3 |
Hashes for aiohttp-3.4.0a0-cp36-cp36m-macosx_10_10_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 197104c018048082cce2c617a742cb673a2046ae58b305f84435c467cce71423 |
|
MD5 | 59e9e07e55e7bad6a4ca3efe5f116194 |
|
BLAKE2b-256 | 66b6fd6860e20063d8644ffab2a58326372a3cc116c79e7e86dbfdf127ac4341 |
Hashes for aiohttp-3.4.0a0-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe99213170012571b5cf920c00eba029e2da960dc94a297acdfbd4f1030613d3 |
|
MD5 | b747f9b4cefe7bc7a77d037abc103c4e |
|
BLAKE2b-256 | 6a164c9db5718951843bc2df5f336dc5186860d79c3198a56a913960c042f4e4 |
Hashes for aiohttp-3.4.0a0-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10435eceb05bc01999c9710764e8cb3c2321fe6f62e1c3bbc9223069ceda84af |
|
MD5 | 0b0562cdefd69059d366c73f9f380499 |
|
BLAKE2b-256 | f311646091ec5f036cb7b925766cf3b048559aa29f569a97d3990ff8df806fc0 |
Hashes for aiohttp-3.4.0a0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5853be2893ab4080c462a393c561112d5101de4d765d5fed7d02341618f9afa |
|
MD5 | 3f9d4ec8eea72a73e0f6dd53ced11eb7 |
|
BLAKE2b-256 | ea17b83bbd725d74db54c2b69ba416390394a0d969395c43b8e00f510915e930 |
Hashes for aiohttp-3.4.0a0-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fa79cbf74099d835a666b8918a25693f23e630a88ce4c4c60b82688029639d7 |
|
MD5 | 8f1a4ad561b0062de2659598b419ad74 |
|
BLAKE2b-256 | e6c924e5b31bdf67b00fce7eb1d0c34d8e063b8f205cb4e1fb1fad9ad4ce5e1d |
Hashes for aiohttp-3.4.0a0-cp35-cp35m-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0c1b1152525b93555c5ac4cdc488b78a3eb1b1121c43f7982920129dc3909379 |
|
MD5 | 425c401940dae92e4325f516af31a46c |
|
BLAKE2b-256 | 15ee59d5209a951a46ea54472a2d7fe93fa4d5cb267ca49238f9ee2e5a4ca461 |
Hashes for aiohttp-3.4.0a0-cp35-cp35m-macosx_10_11_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 085fa92d2995a1208a60018e15d8690228f3e2f028c93a25246be73e4ccf4db1 |
|
MD5 | 6e92bc469209805e32a4280d139e8b1c |
|
BLAKE2b-256 | c891dcc588d2e2e60b292ff086b049d63019124207bec191e00ed9c474aaa9dd |
Hashes for aiohttp-3.4.0a0-cp35-cp35m-macosx_10_10_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe68f893d7ade7e8d3600f32678f0c306ae9de744e9515b8baa5d3192b28e0a0 |
|
MD5 | 1c583bbb50304180eda82b6c7a52f9a7 |
|
BLAKE2b-256 | 2b6abb23547b02237dd965ed900d1561bded05bd2c1a2cf1259d6945ab2f24d2 |