Skip to main content

Return HTTP responses in a easier way

Project description

settings.py

MIDDLEWARE_CLASSES = (
    ...
    # last on the list
    django_simple_response.middleware.SimpleResponseMiddleware,
)

views.py

def view(request):
    # return HTTP response with status code 200 (default)
    return

def another_view(request):
    # return HTTP response with content and status code 401
    return 401, 'Not authorized'

def yet_another_view(request):
    # return JSON/JSONP response with content and default status code
    return {'foo': 'bar'}

In a nutshell, you can either return:

  1. an object, which will be serialized into the response’s content.

  2. a tuple, which first element defines the status code and the second the content of the response.

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

django-easy-response-1.0.1.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

django_easy_response-1.0.1-py2-none-any.whl (6.5 kB view details)

Uploaded Python 2

File details

Details for the file django-easy-response-1.0.1.tar.gz.

File metadata

File hashes

Hashes for django-easy-response-1.0.1.tar.gz
Algorithm Hash digest
SHA256 1d3619930a6bce4dcf5c9ddaac047617f772727f459b1c9a284b9904b07c0b93
MD5 adb06aedfa6fd62efc2f465508adb262
BLAKE2b-256 d38ec63f4636cbc5ef7889f3f661faddc8972df034062ae1f0f1caeed1af8046

See more details on using hashes here.

File details

Details for the file django_easy_response-1.0.1-py2-none-any.whl.

File metadata

File hashes

Hashes for django_easy_response-1.0.1-py2-none-any.whl
Algorithm Hash digest
SHA256 387d9e0f967146ed5be174922a24be16a647a414084ef35e669fc8f4d6a6c159
MD5 5bc91787572f2c11dd3416e0370e3e08
BLAKE2b-256 b29941b72b588095ec5d5639340b426884692fad425f5b068c1c0fd5d00c2068

See more details on using hashes here.

Supported by

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