Skip to main content

No project description provided

Project description

Status Codes Package

A Python package that provides functions for HTTP status codes, allowing you to easily generate responses with predefined or custom messages. This package is useful for handling API responses in web development.

Features

Predefined HTTP Status Codes: Functions for common HTTP status codes like 200 (OK), 404 (Not Found), 500 (Internal Server Error), and more. Custom Message Support: Optionally provide a custom message for any status code response. Easy Integration: Simple functions that return dictionaries with the status code and message.

Installation

You can install the package using pip:

Usage

You can use the functions from the status_codes package to get HTTP responses with status codes and messages.

Example:

from status_codes import StatusCodes

  1. Using default messages
response = StatusCodes.ok_200()
print(response)  # Outputs: {'status': 200, 'message': 'Request succeeded.'}
  1. Using custom messages
response = StatusCodes.ok_200("Custom success message")
print(response)  # Outputs: {'status': 200, 'message': 'Custom success message'}

Available Functions

Here is a list of the available status code functions, each with an optional custom_message parameter:

Informational 1xx

  • continue_100
  • switching_protocols_101
  • processing_102
  • early_hints_103

Successful 2xx

  • ok_200
  • created_201
  • accepted_202
  • non_authoritative_information_203
  • no_content_204
  • reset_content_205
  • partial_content_206
  • multi_status_207
  • already_reported_208
  • im_used_226

Redirection 3xx

  • multiple_choices_300
  • moved_permanently_301
  • found_302
  • see_other_303
  • not_modified_304
  • use_proxy_305
  • use_proxy_306
  • temporary_redirect_307
  • permanent_redirect_308

Client Error 4xx

  • bad_request_400
  • unauthorized_401
  • payment_required_402
  • forbidden_403
  • not_found_404
  • method_not_allowed_405
  • not_acceptable_406
  • proxy_authentication_required_407
  • request_timeout_408
  • conflict_409
  • gone_410
  • length_required_411
  • precondition_failed_412
  • payload_too_large_413
  • uri_too_long_414
  • unsupported_media_type_415
  • range_not_satisfiable_416
  • expectation_failed_417
  • im_a_teapot_418
  • misdirected_request_421
  • unprocessable_content_422
  • locked_423
  • failed_dependency_424
  • too_early_425
  • upgrade_required_426
  • precondition_required_428
  • too_many_requests_429
  • request_header_fields_too_large_431
  • unavailable_for_legal_reasons_451

Server Error 5xx

  • internal_server_error_500
  • not_implemented_501
  • bad_gateway_502
  • service_unavailable_503
  • gateway_timeout_504
  • http_version_not_supported_505
  • variant_also_negotiates_506
  • insufficient_storage_507
  • loop_detected_508
  • not_extended_510
  • network_authentication_required_511

Customization

Each function in the StatusCodes class allows you to pass an optional custom_message parameter. If no message is provided, the function uses a default message associated with the status code.

Using custom message

response = StatusCodes.bad_request_400("Custom bad request message") Outputs: {'status': 400, 'message': 'Custom bad request message'}

If no custom message is passed, it will use the default message:

Without using custom message(ie., default)

response = StatusCodes.bad_request_400() Outputs: {'status': 400, 'message': 'Bad request syntax.'}

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

status_codes-1.0.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

status_codes-1.0.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: status_codes-1.0.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for status_codes-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9f99d65d6e46d6b6fdc8b070f206b8f6b7713aa7f7b47fdfc234fe319e16fdb4
MD5 c210ccf3c0378c1be111ff89703386c0
BLAKE2b-256 9f896535a30ba62fd32c7f379c77b9f41e8236b93e0b61322c1fb7d11a94b819

See more details on using hashes here.

File details

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

File metadata

  • Download URL: status_codes-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for status_codes-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6cbb6c140d0516d85bd7b7d997354817b40fb3a59a7140b07967c40cc0dcd35b
MD5 3c62cb32adf101f59cff4204f9a922e0
BLAKE2b-256 187df498b9462acea6e32f90750a6aab8353417f889675fef00e6ccb1c166b5e

See more details on using hashes here.

Supported by

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