Lightweight wrapper to make http(s) requests. POST, PATCH, and DELETE requests only support json content.
Project description
JSONRequest
Lightweight wrapper for requests library that only supports Content-Type: application/json.
This only supports GET
, POST
, PATCH
, and DELETE
http(s) request methods.
How to Use
First, install the package
pip install jsonrequest
Then, you can use the package.
>>> from jsonrequest import RequestModel, make_request
>>> r = make_request(RequestModel(endpoint="", method='GET', url='https://google.com'))
>>> r
<Response [200]>
>>>
Note:
This data passed also only applies to application/json
content.
Across multiple times over the past many years in my python projects, I found this codeblock repeated whenever I tried to make various http(s) requests using the requests library and thought it'd be much simpler to pass the method as a parameter instead of changing the function. Here's a medium article of how I created this package as a result. Hope this helps and Happy coding :)
- by Justin
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
File details
Details for the file jsonrequest-0.1.7.tar.gz
.
File metadata
- Download URL: jsonrequest-0.1.7.tar.gz
- Upload date:
- Size: 2.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02a13e2e42fc1ebca518322b32771ed65fe416bf6ae265e3dd7b2ff41d12041a |
|
MD5 | 031a922bed834c7eed9bc4002e94acf7 |
|
BLAKE2b-256 | 0cb6dae01e42b373f442c085d3a4c0901c15e5e203026e907ce331f40fe18c18 |