From ffffa1254e2135cc2e5283bb047a9b9e01413fc6 Mon Sep 17 00:00:00 2001 From: Laurent Date: Sun, 28 Dec 2025 11:24:11 +0100 Subject: [PATCH] Add customer API stub --- api-customer/.idea/.gitignore | 10 ++++++++ api-customer/.idea/api-customer.iml | 21 ++++++++++++++++ .../inspectionProfiles/Project_Default.xml | 12 +++++++++ .../inspectionProfiles/profiles_settings.xml | 6 +++++ api-customer/.idea/misc.xml | 7 ++++++ api-customer/.idea/modules.xml | 8 ++++++ api-customer/.idea/vcs.xml | 6 +++++ api-customer/Dockerfile | 17 +++++++++++++ api-customer/app.py | 12 +++++++++ api-customer/docker-compose.yml | 25 +++++++++++++++++++ api-customer/mongo-init/mongo-init.js | 12 +++++++++ api-customer/requirements.txt | 1 + rpi/board-detector/realtime_detect.py | 1 - 13 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 api-customer/.idea/.gitignore create mode 100644 api-customer/.idea/api-customer.iml create mode 100644 api-customer/.idea/inspectionProfiles/Project_Default.xml create mode 100644 api-customer/.idea/inspectionProfiles/profiles_settings.xml create mode 100644 api-customer/.idea/misc.xml create mode 100644 api-customer/.idea/modules.xml create mode 100644 api-customer/.idea/vcs.xml create mode 100644 api-customer/Dockerfile create mode 100644 api-customer/app.py create mode 100644 api-customer/docker-compose.yml create mode 100644 api-customer/mongo-init/mongo-init.js create mode 100644 api-customer/requirements.txt diff --git a/api-customer/.idea/.gitignore b/api-customer/.idea/.gitignore new file mode 100644 index 00000000..ab1f4164 --- /dev/null +++ b/api-customer/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/api-customer/.idea/api-customer.iml b/api-customer/.idea/api-customer.iml new file mode 100644 index 00000000..19684c0d --- /dev/null +++ b/api-customer/.idea/api-customer.iml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/api-customer/.idea/inspectionProfiles/Project_Default.xml b/api-customer/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 00000000..450dc66c --- /dev/null +++ b/api-customer/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/api-customer/.idea/inspectionProfiles/profiles_settings.xml b/api-customer/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 00000000..105ce2da --- /dev/null +++ b/api-customer/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/api-customer/.idea/misc.xml b/api-customer/.idea/misc.xml new file mode 100644 index 00000000..6772093a --- /dev/null +++ b/api-customer/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/api-customer/.idea/modules.xml b/api-customer/.idea/modules.xml new file mode 100644 index 00000000..be89c234 --- /dev/null +++ b/api-customer/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/api-customer/.idea/vcs.xml b/api-customer/.idea/vcs.xml new file mode 100644 index 00000000..6c0b8635 --- /dev/null +++ b/api-customer/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/api-customer/Dockerfile b/api-customer/Dockerfile new file mode 100644 index 00000000..e75908b6 --- /dev/null +++ b/api-customer/Dockerfile @@ -0,0 +1,17 @@ +FROM python:3.12-slim + +WORKDIR /app + +COPY requirements.txt . + +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +ENV FLASK_APP=app.py +ENV FLASK_RUN_HOST=0.0.0.0 +ENV FLASK_RUN_PORT=5000 + +EXPOSE 5000 + +CMD ["flask", "run"] \ No newline at end of file diff --git a/api-customer/app.py b/api-customer/app.py new file mode 100644 index 00000000..4b059ec9 --- /dev/null +++ b/api-customer/app.py @@ -0,0 +1,12 @@ +from flask import Flask + +app = Flask(__name__) + + +@app.route('/') +def hello_world(): + return 'Hello World!' + + +if __name__ == '__main__': + app.run() diff --git a/api-customer/docker-compose.yml b/api-customer/docker-compose.yml new file mode 100644 index 00000000..337198f3 --- /dev/null +++ b/api-customer/docker-compose.yml @@ -0,0 +1,25 @@ +version: "3.8" + +services: + customer-api: + build: . + container_name: "clask-API" + ports: + - "5000:5000" + depends_on: + - mongo + environment: + - MONGO_URI=mongodb://mongo:27017/mydb + + mongo: + image: mongo:latest + container_name: "customer-database" + environment: + - MONGO_INITDB_DATABASE=customer-db + - MONGO_INITDB_ROOT_PASSWORD=secret + - MONGO_INITDB_ROOT_USERNAME=root + ports: + - "27017:27017" + volumes: + - ./mongo-data:/data/db + - ./mongo-init:/docker-entrypoint-initdb.d \ No newline at end of file diff --git a/api-customer/mongo-init/mongo-init.js b/api-customer/mongo-init/mongo-init.js new file mode 100644 index 00000000..9e5341da --- /dev/null +++ b/api-customer/mongo-init/mongo-init.js @@ -0,0 +1,12 @@ +db = db.getSiblingDB("customer-db"); + +db.createCollection("systems"); +db.createCollection("games"); + +db.createUser({ + user: "user", + pwd: "psk358xpg", + roles: [ + { role: "readWrite", db: "customer-db" } + ] +}); diff --git a/api-customer/requirements.txt b/api-customer/requirements.txt new file mode 100644 index 00000000..8ab6294c --- /dev/null +++ b/api-customer/requirements.txt @@ -0,0 +1 @@ +flask \ No newline at end of file diff --git a/rpi/board-detector/realtime_detect.py b/rpi/board-detector/realtime_detect.py index 91fe055a..ee0542fd 100644 --- a/rpi/board-detector/realtime_detect.py +++ b/rpi/board-detector/realtime_detect.py @@ -46,7 +46,6 @@ if __name__ == "__main__": cv2.namedWindow("Predictions", cv2.WINDOW_NORMAL) while True: - time.sleep(1) ret, frame = cap.read() if not ret: