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', auth=aiohttp.BasicAuth('user', 'password'))
text = await response.text()
json = await response.json()
return response, text, json
r, text, json = asyncio.run(main())
>>> r
<ClientResponse(https://api.github.com/) [200 OK]>
>>> r.status
200
>>> r.headers['Content-Type']
'application/json; charset=utf-8'
>>> r.get_encoding()
'utf-8'
>>> text
'{"current_user_url":"https://api.github.com/user",...'
>>> json
{'current_user_url': 'https://api.github.com/user', ... }
The requests object is just proxying get and other HTTP verb methods to aiohttp.ClientSession, which returns aiohttp.ClientResponse. To do anything else, read the aiohttp doc.
Links & Contact Info
PyPI Package: https://pypi.python.org/pypi/aiohttp-requests
GitHub Source: https://github.com/maxzheng/aiohttp-requests
Report Issues/Bugs: https://github.com/maxzheng/aiohttp-requests/issues
Connect: https://www.linkedin.com/in/maxzheng
Contact: maxzheng.os @t gmail.com
Project details
Release history Release notifications | RSS feed
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.2.2.tar.gz
(6.4 kB
view hashes)
Built Distribution
Close
Hashes for aiohttp_requests-0.2.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0328ba190fbe78d9568b3aecdc3970e29d8bbe1569aa6f3777dd1860b21a22ca |
|
MD5 | 1ac5434c8cdeb30e06f20835b98dbbb4 |
|
BLAKE2b-256 | d47afd7e64f20767bc2ab25207875cd44980826169088e114f3b8cb6de00e6ec |