{"id":24129308,"url":"https://github.com/emmo00/flask-status","last_synced_at":"2025-09-18T21:32:12.632Z","repository":{"id":196213533,"uuid":"694147743","full_name":"Emmo00/flask-status","owner":"Emmo00","description":"The Flask Status Extension is a simple Flask extension that adds a status ping route to your Flask application. It allows you to easily check the health and status of your application or services by accessing a designated endpoint.","archived":false,"fork":false,"pushed_at":"2023-12-25T21:46:23.000Z","size":24,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2024-04-26T19:04:00.270Z","etag":null,"topics":["extension","flask","pip","python"],"latest_commit_sha":null,"homepage":"https://github.com/Emmo00/flask-status","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Emmo00.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-20T12:26:29.000Z","updated_at":"2024-02-01T16:50:59.000Z","dependencies_parsed_at":"2024-11-16T03:13:47.963Z","dependency_job_id":"f8799156-6a99-4bc4-847e-450761d47307","html_url":"https://github.com/Emmo00/flask-status","commit_stats":null,"previous_names":["emmo00/flask-status"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Emmo00%2Fflask-status","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Emmo00%2Fflask-status/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Emmo00%2Fflask-status/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Emmo00%2Fflask-status/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Emmo00","download_url":"https://codeload.github.com/Emmo00/flask-status/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233526107,"owners_count":18689431,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["extension","flask","pip","python"],"created_at":"2025-01-11T19:31:19.388Z","updated_at":"2025-09-18T21:32:07.341Z","avatar_url":"https://github.com/Emmo00.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flask-Status\n\n[![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)\n\nThe Flask Status Extension is a simple Flask extension that adds a status ping route to your Flask application. It allows you to easily check the health and status of your application or services by accessing a designated endpoint.\n\n## Features\n\n- **Status Endpoint**: Adds a status ping endpoint (`/api/status` by default) to your Flask application.\n- **Custom Status Message**: Set a custom status message to provide more specific information about the health of your application.\n- **Add more fields/data to status ping payload**: you can add more fields to the payload. This is helpful in cases where you want to add more info to the returned payload, for example, the state of the database.\n- **Authenticated Ping route**: With `FlaskStatus`, you can now set the status ping route to be only accessed by authenticated users or requests.\n\nSee [below](#usage) for more info.\n\n## Installation\n\nTo install the Flask Status Extension, you can use `pip`:\n\n```bash\npip install flask-status\n```\n\n## Usage\n\nHere's how to use the Flask-Status extension in your Flask application\n\n- Install the package using pip\n\n- create a file `main.py`\n\n- Add the following to `main.py`\n\n```python\nfrom flask import Flask\nfrom flask_status import FlaskStatus\n\napp = Flask(__name__)\nFlaskStatus(app)\n\nif __name__ == \"__main__\":\n    app.run(host=\"0.0.0.0\", port=5000)\n```\n\n- run the `main.py` file\n\n```bash\npython3 main.py\n```\n\n- Now go to [http://localhost:5000/api/status](http://localhost:5000/api/status)\n\n- You should see the following\n\n```json\n{\n  \"status\": \"OK\"\n}\n```\n\nYou can also set the route for the status ping, and also the payload returned:\n\n```python\napp = Flask(__name__)\nFlaskStatus(app, url=\"/api/ping\", message={\"message\": \"show my status\"})\n\nif __name__ == \"__main__\":\n    app.run(host=\"0.0.0.0\", port=5000)\n```\n\npayload from [`http://localhost:5000/api/ping`](http://localhost:5000/api/ping):\n\n```json\n{\n  \"message\": \"show my status\"\n}\n```\n\nIf the message is just a string and not a dictionary, example:\n\n```python\nFlaskStatus(app, message=\"Running\")\n```\n\nIt'd be converted to a JSON object payload by putting it in a `message` field as follows follows:\n\n```json\n{\n  \"message\": \"Running\"\n}\n```\n\n### Add more data\n\nAs said above, you can add more data to the status ping payload by using the `.add_field(key, value)` method. Example:\n\n```python\nflask_status = FlaskStatus(app)\n\nflask_status.add_field(\"error\", False)\n\n# you can also add functions to run on request of the status route\ndef check_database():\n    # check if database is running\n    return True\n\nflask_status.add_field(\"database\", check_database)\n```\n\nThe result payload of the above code is as follows:\n\n```json\n{\n    \"status\": \"OK\",\n    \"error\": false,\n    \"database\": true\n}\n```\n\n### Authenticate status route\n\nYou can now also set the status ping route to be for only authenticated users of the API by passing an `authenticator` function which should be a decorator function to the flask route function. Example:\n\n```python\nfrom functools import wraps\n\n# define an authenticator decorator function\ndef login_required(func):\n    @wraps(func)\n    def wrapper(*args, **kwargs):\n        token = request.cookies.get(AUTH_TOKEN_HEADER)\n        if not token:\n            return abort(401)\n        if not verify_token(token):\n            return abort(403)\n        return func(*args, **kwargs)\n  return wrapper\n\n# define FlaskStatus with this authenticator function\nFlaskStatus(app, authenticator=login_required)\n```\n\nThe logic in the `authenticator` function would be run before returning the status payload in this manner:\n\n```python\n@app.route(\"/api/status\")\n@authenticator\ndef status_ping():\n    return jsonify({\"status\": \"OK\"})\n```\n\n## Issues\n\nIf you encounter any issues with this extension or have suggestions for improvements, please create an issue on the [GitHub Issues page](https://github.com/Emmo00/flask-status/issues).\n\nYou are also welcome to contributing to this project.\n\nSpecial thanks to the Flask community\n\n## Author\n\n- [Emmanuel Nwafor](https://github.com/Emmo00)\n\n## Contributors\n\n\u003ca href=\"https://github.com/emmo00/flask-status/graphs/contributors\"\u003e\n\t\u003cp align=\"center\"\u003e\n  \t\t\u003cimg src=\"https://contrib.rocks/image?repo=emmo00/flask-status\" /\u003e\n\t\u003c/p\u003e\n\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femmo00%2Fflask-status","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femmo00%2Fflask-status","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femmo00%2Fflask-status/lists"}