semvec/pypi-packages huggingface dataset:
flask-otpp-healthcheck 0.0.4
A package to return the health status of a flask application

# Installation

```bash
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:

```python
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:

```javascript
{
  "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
    }
  }
}
```