from flask import Flask, request
app = Flask(__name__)

@app.route("/diafaan-callback", methods=["GET", "POST"])
def diafaan_callback():
    print("==== Callback received ====")
    print("Method :", request.method)
    print("Headers:", dict(request.headers))
    print("Args   :", request.args)    # query string for GET
    print("Form   :", request.form)    # form fields for POST
    print("JSON   :", request.get_json(silent=True))
    print("==========================\n", flush=True)
    return "OK"   # must return 200 so Diafaan knows it succeeded

if __name__ == "__main__":
    # Install flask if needed:  pip install flask
    app.run(host="0.0.0.0", port=8088)
