Skip to main content

A Django package that provides an easy-to-use health check url path

Project description

Django-easy-health-check

Django-easy-health-check is a Django package that provides an easy-to-use middleware to allow health check.

Motivation

Django's ALLOWED_HOSTS setting often would prevent health check from being completed successfully in production. A common method of getting around this involves making a request to fetch ip address about the instance itself and adding it to the ALLOWED_HOSTS. This approach often varies depending on deployment platform/environment.

This package provides a simple middleware that allows requests to a specified health check path to be made without checking against ALLOWED_HOSTS setting. This negates the need to modify ALLOWED_HOSTS setting in runtime, and is therefore platform-agnostic.

Quick start

Install using pip:

pip install django-easy-health-check

Or, install from source:

pip install git+https://github.com/oscarychen/django-easy-health-check.git

Add the health check middleware to Django settings before django.middleware.common.CommonMiddleware:

MIDDLEWARE = [
    ...,
    'easy_health_check.middleware.HealthCheckMiddleware',
    'django.middleware.common.CommonMiddleware',
    ...
]

By default, the health check url will be available at "example.com/healthcheck/".

Settings

You can customize and overwrite the default settings by including the following in your project's settings.py:

DJANGO_EASY_HEALTH_CHECK = {
    "PATH": "/healthcheck/",
    "RETURN_STATUS_CODE": 200,
    "RETURN_BYTE_DATA": "",
    "RETURN_HEADERS": None
}

In production, you may also want to set the following Django settings:

ALLOWED_HOSTS = ["example.com"]
SECURE_SSL_REDIRECT = True
SECURE_REDIRECT_EXEMPT = [r'^healthcheck/$']

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-health-check-1.0.1.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

django_easy_health_check-1.0.1-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file django-easy-health-check-1.0.1.tar.gz.

File metadata

  • Download URL: django-easy-health-check-1.0.1.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.6.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for django-easy-health-check-1.0.1.tar.gz
Algorithm Hash digest
SHA256 51b940af823d8fce6c5bd9a41e7d6444dc2d951719a13bd837f585957137b394
MD5 10e93229eab582d145514fe7b9bea0d7
BLAKE2b-256 dd5bac341a51649c76859c95c0ba5c47819239e3b28a8c8e4584130cc60dc90e

See more details on using hashes here.

File details

Details for the file django_easy_health_check-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: django_easy_health_check-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.6.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6

File hashes

Hashes for django_easy_health_check-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 462c8e6ced490a87343557f52bf8e68072668c5d03194c310ad30724df8273b3
MD5 97c77f35e22c2f3dd9916fe91e2066ad
BLAKE2b-256 ed271439ef99e3eb7d8f4c10910c8fb6834527781c740c13dfac18c2d1eb1348

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