From a4ae0170a0ce246c5eae0f0730c50dc3b709b699 Mon Sep 17 00:00:00 2001 From: "ishak jmilou.ishak" Date: Thu, 9 Jan 2025 14:29:54 +0100 Subject: [PATCH] refactor: update sensor_data function to accept data directly instead of JSON string --- src/Python/flask/web/app.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Python/flask/web/app.py b/src/Python/flask/web/app.py index 54db722..e41b580 100644 --- a/src/Python/flask/web/app.py +++ b/src/Python/flask/web/app.py @@ -93,12 +93,11 @@ def database(): cursor.close() return str(rows) -def sensor_data(kobuki_message): +def sensor_data(data): db = get_db() cursor = db.cursor() sql_sensor = "INSERT INTO kobuki_data (name, value) VALUES (%s)" - data_dict = json.loads(kobuki_message) - sensor_data_tuples = [(name, float(value))for name, value in data_dict.items()] + sensor_data_tuples = [(name, float(value))for name, value in data.items()] cursor.executemany(sql_sensor, sensor_data_tuples) db.commit()