Skip to main content

Healthy-API adds a healthcheck endpoint for all web frameworks.

Project description

Healthchecks for Any Framework (FastAPI/Flask)

PyPI GitHub Actions Documentation Status Codecov PyPI - Downloads

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

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)

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.

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

Healthy-API-0.9.0.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

Healthy_API-0.9.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file Healthy-API-0.9.0.tar.gz.

File metadata

  • Download URL: Healthy-API-0.9.0.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for Healthy-API-0.9.0.tar.gz
Algorithm Hash digest
SHA256 14348cac1384373f490dfa2068776c8398f1281b7b74d3920961e1c54d6dee70
MD5 5a602f84277b42f1bf226cbddf6277a9
BLAKE2b-256 8c24f10e586a083b0810b6b183761d35c8bc0261f9ab8795830281f3ba001f37

See more details on using hashes here.

File details

Details for the file Healthy_API-0.9.0-py3-none-any.whl.

File metadata

  • Download URL: Healthy_API-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for Healthy_API-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 248a11d5e4b49a17cb6288b7089e1c0f9f466a108be0b082a6b49b341bcc942a
MD5 6445d76e65cd600987f8f5fbf1e34d52
BLAKE2b-256 0950d59a4a830a64c6c88b5853cc8fb437e92ade896ec7ce0df69237fc353ff7

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