Skip to main content

A package to return the health status of a flask application

Project description

Installation

pip3.7 install --user FlaskHealthCheck #use whatever pip version you have, but this is built for python3+

Requirements

This package relies on a couple of things:

  1. Your Flask application has a file called 'appversion.txt' in its root directory with a line at the top that looks like:
    version: x.x.x (check the flask-template for clarification)

  2. You've got Python 3+ installed as well as Flask and all of your necessary dependencies (obviously, including the package we install here)

Use

Within your routes file that will contain the health check endpoint do the following:

import FlaskHealthCheck

#Add your endpoint like so:
@app.route('/api/healthcheck')
@cross_origin()
@swag_from('../swags/healthcheck/healthcheck.yml') #or wherever your swagger file may be for this endpoint
def health_check():
    return jsonify(FlaskHealthCheck.healthcheck())

Example Return Value

When the endpoint is called from your API, an expected 200 response would look like the following:

{
  "HealthCheckResponse": {
    "AppVersion": "1.0.0",                  //The app version
    "Config": {     
      "CurDir": "/opt/apps/MyWebAPI",       //Root directory of your API
      "IsSuccess": "true",                  //API is reachable (this is a 'to-be-configured' state)
      "MachineName": "MyMachineName",       //The hostname of the box it's being run on
      "PyVersion": "3.7.0 (default, Sep 24 2018, 12:47:32) \n[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]",
      "Uptime": 126.47574424743652,         //How long (in seconds) the service has been up for
      "User": "WebAPIUser"                  //The user which is running the service
    }
  }
}

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for flask-otpp-healthcheck, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size flask_otpp_healthcheck-0.0.4-py3-none-any.whl (4.1 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size flask_otpp_healthcheck-0.0.4.tar.gz (2.5 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page