A class to make HTTP REST requests
Project description
fgslpyrest
Python component to make HTTP RESTful requests.
How to install
pip install fgslpyrest
Using the component
Making a HTTP GET request in the terminal
The sequence of commands below make a HTTP GET request and check if the response has the word "German". The response, in this case, is HTML. The last parameter enables verbose output.
$ python
>>> from fgslpyrest.http.Rest import Rest
>>> rest = Rest()
>>> response = rest.doGet([],"https://time.is/pt_br/UTC",200,True)
>>> print(response.find("German"))
The next sequence of commands make a HTTP request which returns a JSON object.
$ python
>>> import json
>>> from fgslpyrest.http.Rest import Rest
>>> rest = Rest()
>>> response = rest.doGet([],"https://reqres.in/api/users/2",200)
>>> user = json.loads(response)
>>> print(user["data"]["email"])
For developers
- PKG-INFO describes the package in a summarized way.
- MANIFEST.in defines which files will be included into the package.
- pyproject.toml defines the general packaging information.
More information at https://packaging.python.org/en/latest/tutorials/packaging-projects/
Running the unit tests
python -m unittest tests/resttest.py
Building the package
python -m build --sdist .
Requires build
module. You can install it using pip install build
.
Upload the package to PyPI
twine upload dist/*
Troubleshooting
If you try to install and receive a error message with this fragments:
filename has 'fgslpyrest', but metadata has 'unknown'
ERROR: No matching distribution found for fgslpyrest
Then run this command:
pip3 install --upgrade pip
And try to install again.
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
File details
Details for the file fgslpyrest-1.1.3.tar.gz
.
File metadata
- Download URL: fgslpyrest-1.1.3.tar.gz
- Upload date:
- Size: 15.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.26.0 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6b904e80b13ff8b540160ec0238ad9757d1c186cb45a9e1f2dfba4d46a163c7 |
|
MD5 | 745e5bfb7323276c4a3a1939c5357cde |
|
BLAKE2b-256 | 8e3cb96659d36eea7d1435941cf68931aa0b636e7249746789e0ee07935b9dc7 |