added mosquitto setup

Signed-off-by: Ebbe Baß <ebbe.bass>
This commit is contained in:
Ebbe Baß
2024-02-12 21:55:08 +01:00
parent 87521ddce2
commit 982680a1c3
3 changed files with 35 additions and 3 deletions
+10 -2
View File
@@ -1,6 +1,8 @@
from flask import Flask, render_template, request, jsonify
import json
import MySQLdb
import paho.mqtt.client as mqtt
import threading
app = Flask(__name__)
@@ -30,6 +32,8 @@ db = MySQLdb.connect(
database=config['mysql']['database'],
)
mqttc = mqtt.Client("localhost", 1883, 60)
# Function to retrieve registered tubes from the database
def get_tubes():
cur = db.cursor()
@@ -79,8 +83,12 @@ def get_assigned_params(tube_unique_id):
except Exception as e:
return jsonify({'success': False, 'message': f'Error: {e}'})
def main():
def flask_api():
app.run(host='0.0.0.0', port=5000)
def mqtt_publisher(mqtt):
if __name__ == "__main__":
main()
mqtt_publisher(mqtt)
flask_api()