from flask import Flask, request, jsonify

app = Flask(__name__)

# 🔐 SECRET PASSWORD (change this!)
WEBHOOK_PASSWORD = "Raptor@123"

@app.route('/webhook', methods=['POST'])
def webhook():
    data = request.json

    # check password
    password = data.get("password")

    if password != WEBHOOK_PASSWORD:
        return jsonify({
            "status": "error",
            "message": "Unauthorized"
        }), 401

    # remove password before processing
    data.pop("password", None)

    print("Webhook triggered successfully:", data)

    # 👉 Your logic here
    return jsonify({
        "status": "success",
        "message": "Webhook executed"
    })

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=5001)
