init
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user