https://github.com/matt-snider/flask-healthcheck
https://github.com/matt-snider/flask-healthcheck
Last synced: 4 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/matt-snider/flask-healthcheck
- Owner: matt-snider
- License: mit
- Created: 2016-10-21T23:27:54.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-08-06T21:31:11.000Z (almost 8 years ago)
- Last Synced: 2025-06-15T17:16:36.003Z (12 days ago)
- Language: Python
- Size: 13.7 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# flask-healthcheck
Flask-Healthcheck is a [Flask](http://flask.pocoo.org/) extension that provides
a simple way of adding healthchecks to a service.## Example:
```python
from flask import Flask
app = Flask(__name__)
healthcheck = Healthcheck(app)@app.route('/')
def hello_world():
return 'Hello world!'@healthcheck
def connections():
if len(connections) < 5:
return False, 'Less than 5 active connections'
else:
return True
```Making a request against this endoint will return a 200 status code and the
following output when the healthcheck passes:
```json
{
"connections": {
"healthy": true,
}
}
```And, the following if the healthcheck fails:
```json
{
"connections": {
"healthy": false,
"message": "Less than 5 active connections"
}
}
```## Built-in Healthchecks
Healthchecks for some popular Flask extensions are already built in and just
need to be activated:
```python
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy(app)
healthcheck.add_extension('sqlalchemy', db)
```
Here it's important to call `add_extension()` with the proper extension name
and the extension object.