aio-libs/aiohttp


Asynchronous HTTP client/server framework for asyncio and Python

https://docs.aiohttp.org

License: Apache-2.0

Language: Python

Keywords: aiohttp, async, asyncio, http, http-client, http-server, python


Async http client/server framework

aiohttp logo


Travis status for master branch AppVeyor status for master branch codecov.io status for master branch Latest PyPI package version Latest Read The Docs Chat on Gitter

Key Features

  • Supports both client and server side of HTTP protocol.
  • Supports both client and server Web-Sockets out-of-the-box and avoids Callback Hell.
  • Provides Web-server with middlewares and pluggable routing.

Getting started

Client

To get 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

An example using a simple server:

# examples/server_simple.py
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

https://aiohttp.readthedocs.io/

Demos

https://github.com/aio-libs/aiohttp-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

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 its 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 efficiency, the AsyncIO community maintains a list of benchmarks on the official wiki: https://github.com/python/asyncio/wiki/Benchmarks

Project Statistics

Sourcerank 19
Repository Size 12.9 MB
Stars 6,423
Forks 992
Watchers 229
Open issues 179
Dependencies 46
Contributors 391
Tags 182
Created
Last updated
Last pushed

Top Contributors See all

Andrew Svetlov Nikolay Kim pyup.io bot Sviatoslav Sydorenko Alexey Popravka Alexander Shorin Jashandeep Sohi Anton Kasyanov Samuel Colvin Pau Freixes Nikolay Novik Arthur Darcet Vladimir Rutsky redixin Andrew Leech Manuel Miranda Alexander Dutton Louis-Philippe Huberdeau Theron Luhn Cecile Tonglet

Packages Referencing this Repo

aiohttp
Async http client/server framework (asyncio)
Latest release 3.5.0a1 - Updated - 6.42K stars

Recent Tags See all

v3.5.0a1 November 20, 2018
v3.4.4 September 05, 2018
v3.4.3 September 04, 2018
v3.4.2 September 01, 2018
v3.4.1 August 28, 2018
v3.4.0 August 25, 2018
v3.4.0b2 August 24, 2018
v3.4.0b1 August 24, 2018
v3.4.0a3 August 20, 2018
v3.4.0a2 August 19, 2018
v3.4.0a1 August 19, 2018
v3.4.0a0 August 11, 2018
v3.3.2a0 June 12, 2018
v3.3.2 June 12, 2018
v3.3.1 June 05, 2018

Interesting Forks See all

gleb-chipiga/aiohttp
http client/server for asyncio (PEP-3156)
Python - Apache-2.0 - Last pushed - 1 stars
nibrag/aiohttp
Async http client/server framework (asyncio)
Python - Last pushed - 1 stars
tomchristie/aiohttp
Async http client/server framework (asyncio)
Python - Last pushed - 1 stars
antime/aiohttp
Async http client/server framework (asyncio)
Python - Updated - 1 stars
bedreamer/aiohttp
Async http client/server framework (asyncio)
Python - Updated - 1 stars

Something wrong with this page? Make a suggestion

Last synced: 2018-11-20 10:28:11 UTC

Login to resync this repository