het werkt wel, Atilla

This commit is contained in:
Burak
2024-03-19 11:18:04 +01:00
parent 9307640750
commit 9b2e429496
2 changed files with 38 additions and 32 deletions

14
app.py
View File

@@ -34,9 +34,17 @@ def get_data():
if battery_data is None:
return jsonify({"error": "Failed to fetch data from database"})
print(battery_data)
# Convert the fetched data into a dictionary
data_dict = {
"id": battery_data[0],
"timestamp": str(battery_data[1]), # Convert timestamp to string for JSON serialization
"gateway_receive_time": str(battery_data[2]), # Convert timestamp to string for JSON serialization
"device": battery_data[3],
"value": battery_data[4]
}
# Return the data as JSON
return jsonify(data_dict)
if __name__ == "__main__":
app.run(host='127.0.0.1', port=5000)
app.run(host='127.0.0.1', port=5000)