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[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)

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.10.0.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

healthy_api-0.10.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file healthy_api-0.10.0.tar.gz.

File metadata

  • Download URL: healthy_api-0.10.0.tar.gz
  • Upload date:
  • Size: 20.9 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.10.0.tar.gz
Algorithm Hash digest
SHA256 09b51d55845bbce046c69a09ff13f7367cadbaeba838779f13acf7fb3805ef39
MD5 a94892d156377e62451d7769c0a1fed9
BLAKE2b-256 ff8254570dfd93d570938392135db2c1755268c5871444f392e9e105684b7033

See more details on using hashes here.

File details

Details for the file healthy_api-0.10.0-py3-none-any.whl.

File metadata

  • Download URL: healthy_api-0.10.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 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.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 db055218692828dd61bec404dbe5e5c75f9847c5abbd87a80eb0122f5a9fdc28
MD5 f89a57e61c756e4654a1170fa042d3a1
BLAKE2b-256 a1344193a897d4ad2451b4f22dfdb108fbf232998c3db3c30b698872d60d9f5c

See more details on using hashes here.

Supported by

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