HTTP Status for Humans

1.0.1 · abandoned · verified Thu Apr 16

A very simple Python library providing human-understandable HTTP status codes and helper methods to improve code readability. Originally forked from Django Rest Framework, it reached version 1.0.1 in October 2015 and has not seen further updates since, making it an effectively abandoned project.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import and use the `status` library with HTTP status codes and helper functions, often in conjunction with a library like `requests`.

import requests
import status
import os

# Example usage with a requests response
response = requests.get(os.environ.get('TEST_URL', 'https://httpbin.org/status/200'))

if status.is_success(code=response.status_code):
    print(f"Request successful: {response.status_code} {status.phrase(response.status_code)}")
elif status.is_client_error(code=response.status_code):
    print(f"Client error: {response.status_code} {status.phrase(response.status_code)}")
elif status.is_server_error(code=response.status_code):
    print(f"Server error: {response.status_code} {status.phrase(response.status_code)}")

# Direct access to status codes
print(f"HTTP OK: {status.HTTP_200_OK}")
print(f"HTTP Not Found: {status.HTTP_404_NOT_FOUND}")

view raw JSON →