changed db send data to other function

This commit is contained in:
ishak jmilou.ishak
2025-01-09 13:58:34 +01:00
parent 2e4f048ed9
commit e59f235b91

View File

@@ -60,8 +60,16 @@ def control():
@app.route('/data', methods=['GET']) @app.route('/data', methods=['GET'])
def data(): 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 return kobuki_message
@app.route('/move', methods=['POST']) @app.route('/move', methods=['POST'])
def move(): def move():
data = request.get_json() data = request.get_json()
@@ -91,14 +99,6 @@ def database():
cursor.close() cursor.close()
return str(rows) 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__': if __name__ == '__main__':
app.run(debug=True, port=5000) app.run(debug=True, port=5000)