Healthchecks for Any Framework (FastAPI/Flask)
Healthy-API is designed to work with both Flask and FastAPI. Healthy-API is really simple to set up. Healthy-API will provide an enpoint at /_health where you will get a JSON response of the system’s uptime, current git revision, version, and function you want.
You can also add in extra checks by passing in a list of checks to the constructor.
Installing
Install and update using pip:
pip install -U "healthy-api[flask]"
or
pip install -U "healthy-api[fastapi]"
FastAPI Configuration
from fastapi import FastAPI
from healthy_api.adapters.fastapi import FlaskAdapter as HealthyApi
app = FastAPI(__name__)
def db_check():
"""Database"""
try:
with get_session_ctx() as session:
(res,) = session.execute(text("SELECT 1")).fetchone()
return bool(res == 1)
except Exception as e:
logger.error(f"Unable to connect to database: {e}")
return False
HealthyApi(app, extra_checks=[db_check])
Flask Configuration
from Flask import Flask
from healthy_api.adapters.flask import Flask as HealthyApi
app = Flask(__name__)
HealthyApi(app)
Or if you can use the init_app function:
from Flask import Flask
from healthy_api.adapters.flask import Flask as HealthyApi
app = Flask(__name__)
healthy_api = HealthyApi()
healthy_api.init_app(app)
Free software: MIT license
Documentation: https://healthy_api.readthedocs.io.
Features
Current Git Commit
Current Version
Accepts custom functions
Configuration
Config Key |
Description |
Type |
Default |
|---|---|---|---|
HAPI_ENABLE |
Enable/Disable Healthy-API |
bool |
True |
HAPI_ENABLE_GIT |
Enable/Disable Git Stats |
bool |
True |
HAPI_ENABLE_VERSION |
Enable/Disable Version Stats |
bool |
True |
HAPI_ENDPOINT |
Custom Route |
str |
/_health |
Sponsorship
Put your logo here! Become a sponsor and support this project!
Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
Release files for healthy-api 0.11.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| healthy_api-0.11.1.tar.gz | 20.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| healthy_api-0.11.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.2 kB
Release files / healthy_api-0.11.1.tar.gz
| Download URL | healthy_api-0.11.1.tar.gz |
|---|---|
| Size | 20.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f54c55276f74a5583082586e2201afbc791aede891d5f095592d894ed07b6235
|
|
BLAKE2b-256 checksum How to use checksums |
f28c485d70a5ee305633ecdd5e2b3a6d5e6545b14f1b7a80da4a7ea9adf53860
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.8
|
Release files / healthy_api-0.11.1-py3-none-any.whl
| Download URL | healthy_api-0.11.1-py3-none-any.whl |
|---|---|
| Size | 8.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
292e82f337f046aa101cde7f06ffdfeeb468bb83959a1fdbd83f51b120f76314
|
|
BLAKE2b-256 checksum How to use checksums |
81611c82d31e4b61a0741737524aad07b829f298800ef344393900cb59ffbe85
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.8
|