Skip to main content

A thin wrapper for aiohttp client with Requests simplicity

Project description

aiohttp-requests

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('https://api.github.com/user', auth=aiohttp.BasicAuth('user', 'password'))
...     text = await r.text()
...     json = await r.json()
...     return response, content, text, json
...
>>> loop = asyncio.get_event_loop()
>>> r, text, json = loop.run_until_complete(main())
>>>
>>> r
<ClientResponse(https://api.github.com/user) [200 OK]>
>>> r.status
200
>>> r.headers['Content-Type']
'application/json; charset=utf-8'
>>> r.get_encoding()
'utf-8'
>>> text
'{"login":"...'
>>> 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.0.5.tar.gz (5.0 kB view details)

Uploaded Source

File details

Details for the file aiohttp-requests-0.0.5.tar.gz.

File metadata

File hashes

Hashes for aiohttp-requests-0.0.5.tar.gz
Algorithm Hash digest
SHA256 da0a9eaf9ffb3695337b0f37777f5ecdd5edf0fea1fac0191a33f1dbb4a12a7a
MD5 fc208b6d3f38d6e839329cb97c804957
BLAKE2b-256 043ad32ccccb4aaabd0c74ac6053b7b4293968cbca621f9adf0ef2033496ee71

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page