pyinfra/pyinfra/flask.py
Matthias Bisping dccb9ac67a Pull request #10: Endpoint config changes
Merge in RR/pyinfra from endpoint_config_changes to master

Squashed commit of the following:

commit 4392513d1b542ff8b3ca4702827ad656cb27ab4c
Author: Matthias Bisping <matthias.bisping@iqser.com>
Date:   Tue Feb 22 13:50:53 2022 +0100

    fixed comment in config

commit 1ee27db1536ec085fdc3d249aec16bd69a83d73a
Author: Matthias Bisping <matthias.bisping@iqser.com>
Date:   Tue Feb 22 13:47:58 2022 +0100

    fixed minio endpoint in config

commit bc07d5086f30dafc9adf4e6eb6002f92ee3c11a5
Author: Matthias Bisping <matthias.bisping@iqser.com>
Date:   Tue Feb 22 13:31:54 2022 +0100

    config refac

commit 2ad7fc6477cd986647b44fde8a3c0ec5938ec203
Author: Matthias Bisping <matthias.bisping@iqser.com>
Date:   Tue Feb 22 13:21:56 2022 +0100

    refactorig of webserver startup logic
2022-02-23 11:41:14 +01:00

42 lines
865 B
Python

from flask import Flask, jsonify
from waitress import serve
from pyinfra.config import CONFIG
def run_probing_webserver(app, host=None, port=None, mode=None):
if not host:
host = CONFIG.probing_webserver.host
if not port:
port = CONFIG.probing_webserver.port
if not mode:
mode = CONFIG.probing_webserver.mode
if mode == "development":
app.run(host=host, port=port, debug=True)
elif mode == "production":
serve(app, host=host, port=port)
def set_up_probing_webserver():
app = Flask(__name__)
@app.route("/ready", methods=["GET"])
def ready():
resp = jsonify("OK")
resp.status_code = 200
return resp
@app.route("/health", methods=["GET"])
def healthy():
resp = jsonify("OK")
resp.status_code = 200
return resp
return app