From e59f235b91c0b77bf28b4bc412c220c5fcbf89f6 Mon Sep 17 00:00:00 2001 From: "ishak jmilou.ishak" Date: Thu, 9 Jan 2025 13:58:34 +0100 Subject: [PATCH] changed db send data to other function --- src/Python/flask/web/app.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Python/flask/web/app.py b/src/Python/flask/web/app.py index 6fa1f1d..ef2a503 100644 --- a/src/Python/flask/web/app.py +++ b/src/Python/flask/web/app.py @@ -60,8 +60,16 @@ def control(): @app.route('/data', methods=['GET']) def data(): + db = get_db() + cursor = db.cursor() + sql = "INSERT INTO kobuki_data (data) VALUES (%s)" + value = data + cursor.execute(sql, (value,)) + db.commit() + cursor.close() return kobuki_message + @app.route('/move', methods=['POST']) def move(): data = request.get_json() @@ -91,14 +99,6 @@ def database(): cursor.close() return str(rows) -def save_sensor_data(data): - db = get_db() - cursor = db.cursor() - sql = "INSERT INTO kobuki_data (data) VALUES (%s)" - value = data - cursor.execute(sql, (value,)) - db.commit() - cursor.close() if __name__ == '__main__': app.run(debug=True, port=5000)