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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django-easy-health-check-0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8efa8212e742569c5e30c846f9a9ce63c499931fe1301d810debc16a78bd3f2 |
|
MD5 | 79a35fa42b5d5c9d5005827e76dddbd4 |
|
BLAKE2b-256 | 25dac1b81392f0a3c77f7d2133384ebe4b6a8b189a1b42364f4134060d9c36b6 |
Hashes for django_easy_health_check-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1be95067717f03e4f769e14f0fa5f96daa0ebd3e469c5b8e3a53b0b1d437288b |
|
MD5 | d39a06d33de0c0899b4d803af855eab1 |
|
BLAKE2b-256 | e6bcebead64eb9c6cd55403ebf6b50463f454c897bf17a1335b1a8042b66f689 |