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 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(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.1.1.tar.gz (5.5 kB view details)

Uploaded Source

File details

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

File metadata

File hashes

Hashes for aiohttp-requests-0.1.1.tar.gz
Algorithm Hash digest
SHA256 083437113940739b01e5273a996760c9e9a7ae2718487238443b5d1f4e6e91e4
MD5 957b98ac49ed574584d5f1f3e9c6a15e
BLAKE2b-256 d4c8a443a0c17dc7e91bd8a5ae9a6dcc860a3ae8af9b7e40fd336448c456a2da

See more details on using hashes here.

Supported by

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