From 81c3874b0450a5735001bdfc556cc41b32f6ce04 Mon Sep 17 00:00:00 2001 From: Laurent Date: Sun, 4 Jan 2026 12:20:30 +0100 Subject: [PATCH] Add debug statement --- api-customer/app.py | 2 +- api-customer/src/services/mongo_service.py | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/api-customer/app.py b/api-customer/app.py index f71c556a..0f6151ce 100644 --- a/api-customer/app.py +++ b/api-customer/app.py @@ -44,4 +44,4 @@ if __name__ == '__main__': auth_controller.set_on_login(handle_login) - app.run(host="0.0.0.0", port=5000, debug=True) + app.run(host="0.0.0.0", port=5000, debug=True, use_reloader=False) diff --git a/api-customer/src/services/mongo_service.py b/api-customer/src/services/mongo_service.py index 702075bd..55743c0e 100644 --- a/api-customer/src/services/mongo_service.py +++ b/api-customer/src/services/mongo_service.py @@ -15,14 +15,20 @@ class MongoService: def insert(self, collection : str, data : object): - collection = self._db[collection] - payload = self._to_document(data) - result = collection.insert_one(payload) - return result.inserted_id + try : + collection = self._db[collection] + payload = self._to_document(data) + result = collection.insert_one(payload) + return result.inserted_id + except Exception as e: + print(e) def find(self, collection: str, field: str, value): - col = self._db[collection] - return list(col.find({field: value})) + try : + collection = self._db[collection] + return list(collection.find({field: value})) + except Exception as e: + print(e) def _to_document(self, obj): if obj is None or isinstance(obj, (str, int, float, bool)):