From 9b2e429496df875bf0df03dce490c6eafc5880ae Mon Sep 17 00:00:00 2001 From: Burak <6028083@mborijnland.nl> Date: Tue, 19 Mar 2024 11:18:04 +0100 Subject: [PATCH] het werkt wel, Atilla --- app.py | 14 +++++++++--- package-lock.json | 56 +++++++++++++++++++++++------------------------ 2 files changed, 38 insertions(+), 32 deletions(-) diff --git a/app.py b/app.py index 93f7165..e91b0fc 100644 --- a/app.py +++ b/app.py @@ -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) \ No newline at end of file + app.run(host='127.0.0.1', port=5000) diff --git a/package-lock.json b/package-lock.json index 8cef48b..e37043a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,18 +21,6 @@ "wait-on": "^7.2.0" } }, - "node_modules/@babel/runtime": { - "version": "7.24.0", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.0.tgz", - "integrity": "sha512-Chk32uHMg6TnQdvw2e9IlqPpFX/6NLuK0Ys2PqLb7/gL5uFn9mXvK715FGLlOLQrcO4qIkNHkvPGktzzXexsFw==", - "dev": true, - "dependencies": { - "regenerator-runtime": "^0.14.0" - }, - "engines": { - "node": ">=6.9.0" - } - }, "es-errors": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", @@ -69,6 +57,18 @@ "which": "bin/which" } }, + "node_modules/@babel/runtime": { + "version": "7.24.0", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.24.0.tgz", + "integrity": "sha512-Chk32uHMg6TnQdvw2e9IlqPpFX/6NLuK0Ys2PqLb7/gL5uFn9mXvK715FGLlOLQrcO4qIkNHkvPGktzzXexsFw==", + "dev": true, + "dependencies": { + "regenerator-runtime": "^0.14.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@electron/get": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@electron/get/-/get-2.0.3.tgz", @@ -2726,7 +2726,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/spawn-command": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/spawn-command/-/spawn-command-0.0.2.tgz", @@ -2961,7 +2960,6 @@ "tree-kill": "cli.js" } }, - "node_modules/tslib": { "version": "2.6.2", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", @@ -3196,21 +3194,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/wrap-ansi/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", @@ -3228,6 +3211,21 @@ "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, + "node_modules/wrap-ansi/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/wrap-ansi/node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",