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.
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
Follow: https://twitter.com/MaxZhengX
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
Built Distribution
File details
Details for the file aiohttp-requests-0.1.2.tar.gz
.
File metadata
- Download URL: aiohttp-requests-0.1.2.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7204ea79c733499912392033d3e49318ac90babfb9df443b1625f714c9c66776 |
|
MD5 | c76f4f0e3e5bee78ae0fc0cabc2171cf |
|
BLAKE2b-256 | c0c40d5b912e123102bc42af05dbdef1cd4f239595efe784b2873125cdee2459 |
File details
Details for the file aiohttp_requests-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: aiohttp_requests-0.1.2-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c23e4ffb5f62c0741ec495e9336f0b45a0ebf2dd0330e4e4854c81c87541963f |
|
MD5 | 5bb0b8d74531de4653820891f939b83a |
|
BLAKE2b-256 | e3e8eadb96adc5ed94d6afa111b34324df05d2078152230196b9fb8adbe282f6 |