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.

Source Distribution

aiohttp-requests-0.1.3.tar.gz (5.6 kB view hashes)

Uploaded source

Built Distribution

aiohttp_requests-0.1.3-py3-none-any.whl (4.0 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page