Skip to main content

Pretty print your python HTTP requests

Project description

            Tests Passing    GitHub pull requests    License


Report Bug · Request Feature · Ask Question · Report security bug


Alt


requests-pprint is a Python script that allows you to print your HTTP requests and responses in a pretty format. It is based on the requests library and uses the rich library to print the response in a more readable way.

Table of Contents

Requirements

Here's a breakdown of the packages needed and their versions:

[!NOTE]
The software has been developed and tested using Python 3.12.1. The minimum required version to run the software is Python 3.6. Although the software may work with previous versions, it is not guaranteed.

Installation

From PyPI

requests-pprint can be installed easily as a PyPI package. Just run the following command:

pip3 install requests-pprint

[!IMPORTANT]
For best practices and to avoid potential conflicts with your global Python environment, it is strongly recommended to install this program within a virtual environment. Avoid using the --user option for global installations. We highly recommend using pipx for a safe and isolated installation experience. Therefore, the appropriate command to install requests-pprint would be:

pipx install requests-pprint

Manual installation

If you prefer to install the program manually, follow these steps:

[!NOTE]
This will install the version from the latest commit, not the latest release.

  1. Download the latest version of requests-pprint from this repository:

    git clone https://github.com/YisusChrist/requests-pprint
    cd requests-pprint
    
  2. Install the package:

    poetry install
    

Uninstall

If you installed it from PyPI, you can use the following command:

pipx uninstall requests-pprint

Usage

1. Pretty Print HTTP Request

import requests
from requests_pprint import pprint_http_request

# Prepare a sample HTTP request
url = 'https://api.example.com'
headers = {'User-Agent': 'Mozilla/5.0'}
body = {'key': 'value'}
request = requests.Request('POST', url, headers=headers, json=body)
prepared_request = request.prepare()

# Print the formatted HTTP request
pprint_http_request(prepared_request)

Output:

1

2. Pretty Print HTTP Response

import requests
from requests_pprint import pprint_http_response

# Send a sample HTTP request
response = requests.get('https://example.com')

# Print the formatted HTTP response
pprint_http_response(response)

Output:

2

3. Print Response Summary

import requests
from requests_pprint import print_response_summary

# Send a sample HTTP request
response = requests.get('https://example.com')

# Print a summary of the HTTP response
print_response_summary(response)

Output:

3

Contributors

How do I contribute to requests-pprint?

Before you participate in our delightful community, please read the code of conduct.

I'm far from being an expert and suspect there are many ways to improve – if you have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send pull requests!

We also need people to test out pull requests. So take a look through the open issues and help where you can.

See Contributing for more details.

License

requests-pprint is released under the GPL-3.0 License.

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

requests_pprint-1.0.0.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

requests_pprint-1.0.0-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file requests_pprint-1.0.0.tar.gz.

File metadata

  • Download URL: requests_pprint-1.0.0.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.1 Windows/11

File hashes

Hashes for requests_pprint-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7e74dcb3a1bf1e5331e8e376f6b1af9aa10e6d259caefa5dda91ece03e32779b
MD5 b3ea201377c53fbdecdc945188a9efde
BLAKE2b-256 65e69c24cc94e637d0eef7df88605501dfe2bb0c49f4e27ed564913609d08009

See more details on using hashes here.

File details

Details for the file requests_pprint-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: requests_pprint-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.1 Windows/11

File hashes

Hashes for requests_pprint-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 151a5710def9fc448a609b3c21ac5571f727661a238f1f4067eaee4b4cf62f84
MD5 7ed8e26e564cd31a4d28216e7a9d9b4e
BLAKE2b-256 02afc3b8d6c36b298b5f2153a85f3343cab356ebd5623d1e3efaa2850a94bb66

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page