Skip to main content

A thin wrapper for aiohttp client with Requests simplicity

Project description


Behold, the power of aiohttp client with Requests simplicity:

>>> import asyncio
>>> import aiohttp
>>> from aiohttp_requests import requests
>>> async def main():
...     response = await requests.get('', auth=aiohttp.BasicAuth('user', 'password'))
...     text = await response.text()
...     json = await response.json()
...     return response, text, json
>>> loop = asyncio.get_event_loop()
>>> r, text, json = loop.run_until_complete(main())
>>> r
<ClientResponse( [200 OK]>
>>> r.status
>>> r.headers['Content-Type']
'application/json; charset=utf-8'
>>> r.get_encoding()
>>> text
>>> json
{'login': 'user', 'public_repos': 28, ...}

The requests object is just proxying get and any other HTTP verb methods to aiohttp.ClientSession, which returns aiohttp.ClientResponse. To do anything else, just read the aiohttp doc.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for aiohttp-requests, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size aiohttp_requests-0.1.2-py3-none-any.whl (3.1 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size aiohttp-requests-0.1.2.tar.gz (5.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page