An HTTP asynchronous client.
Project description
HTTPlus
An HTTP asynchronous client.
Instalation
pip install httplus
Basic Usage
The simplest request using get method is showed below.
import httplus
...
client = httplus.Client()
res = await client.get('http://someserver/api/collection')
print(res.status)
# 200
data = res.json()
# {...}
A request is executed by Client instance class. The Client class has get, post, put, delete, options, patch and head methods to do requests.
Examples
Sending data through POST request
import httplus
...
data = {
'name': 'Vink',
'surname': 'Blaster'
}
client = httplus.Client()
res = await client.post('http://someserver/api/customers', data=data)
print(res.status)
# 200
The data parameter can be a dict, list or a binary object. A dict or a list passed by data param will be interpreted like JSON format data. If a binary data like a pdf or an image file is been sending, a header content mime type need to be informed by headers param.
import httplus
...
image = b'<some_image_binary>'
headers = {
'Content-Type': 'image/png'
}
url = 'http://someserver/api/books'
...
client = httplus.Client()
res = await client.post(url=url, data=image, headers=headers)
print(res.status)
# 200
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
httplus-0.1.2.tar.gz
(4.1 kB
view details)
Built Distribution
File details
Details for the file httplus-0.1.2.tar.gz
.
File metadata
- Download URL: httplus-0.1.2.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/5.19.0-46-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 957a61a2fe93186bb0217f6ab1980732a995337b51254ba242d3538d4fbbb705 |
|
MD5 | a8354a72e644af38bc3a9d604dbe4d96 |
|
BLAKE2b-256 | 03cfea8e718ed761c7558a7c83cd0aaa2a56c6c72a466cfedbc3692e3ee3d69d |
File details
Details for the file httplus-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: httplus-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.6 Linux/5.19.0-46-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e305d178dca09040207101ccc88ebc7f67531ec19debcecdcd67ae41e1743c66 |
|
MD5 | ff1fbf4ccb437d8b3f919efd55890add |
|
BLAKE2b-256 | f8e03f4f241ecc3d3187f5069e928d9db87bdb9202c3c43dd43ef950db96f982 |