This commit is contained in:
2025-10-17 17:02:23 +02:00
parent fa64ed8d4a
commit 252b1390fe
4 changed files with 15 additions and 7 deletions

View File

@@ -1,20 +1,21 @@
from flask import Flask, request, jsonify
from Sender import send_to_queue
import xmltodict
app = Flask(__name__)
@app.route("/send", methods=["POST"])
def send():
# očekává JSON payload
payload = request.get_json()
if not payload:
return jsonify({"error": "No JSON payload provided"}), 400
xml_payload = request.data.decode('utf-8')
try:
send_to_queue(payload) # voláme funkci z sender.py
payload_dict = xmltodict.parse(xml_payload) # převede XML na dict
send_to_queue(payload_dict) # pošle se do Sender.py
return jsonify({"status": "ok"}), 200
except Exception as e:
return jsonify({"error": str(e)}), 500
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000)