From 0b40f63af0a3c9f57708fa9ed4fb4b1f3376fefa Mon Sep 17 00:00:00 2001 From: "ishak jmilou.ishak" Date: Tue, 22 Oct 2024 14:53:14 +0200 Subject: [PATCH] made print to see if message is sent correctly --- src/Python/flask/web/app.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Python/flask/web/app.py b/src/Python/flask/web/app.py index b70a311..de37ea0 100644 --- a/src/Python/flask/web/app.py +++ b/src/Python/flask/web/app.py @@ -8,7 +8,6 @@ mqtt_client = mqtt.Client() # Verbinding maken met de Raspberry Pi (broker) mqtt_client.username_pw_set("ishak", "kobuki") mqtt_client.connect("ishakpi.ddns.net", 1883, 60) -client = mqtt.Client(protocol=mqtt.MQTTv311) @app.route('/') def index(): @@ -16,8 +15,12 @@ def index(): @app.route('/move', methods=['POST']) def move(): - mqtt_client.publish("home/commands", "Knop ingedrukt!") - return "Bericht verzonden!" + result = mqtt_client.publish("home/commands", "Knop ingedrukt!") + if result.rc == mqtt.MQTT_ERR_SUCCESS: + print("Bericht succesvol gepubliceerd") + else: + print("Fout bij het publiceren van bericht") + return "Bericht verzonden!" if __name__ == '__main__': app.run(debug=True) \ No newline at end of file