From ef0ba492423c66732cbe2d83f6d341c906d609c3 Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Fri, 22 May 2026 10:56:32 +0200 Subject: [PATCH 1/8] Add version to config.json --- config.json | 1 + 1 file changed, 1 insertion(+) diff --git a/config.json b/config.json index c62f739..612ac08 100644 --- a/config.json +++ b/config.json @@ -1,5 +1,6 @@ { "projet": "TP-Git-Collaboratif", + "version": "1.1.0", "promotion": "DevSecOps Azure — Simplon", "apprenants": [], "api": { From 6c893c42089eb701b56165ed08c5a9e7842191c2 Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Fri, 22 May 2026 10:59:03 +0200 Subject: [PATCH 2/8] Add api/health route --- python-api/app.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/python-api/app.py b/python-api/app.py index bc7c4b5..ca83129 100644 --- a/python-api/app.py +++ b/python-api/app.py @@ -5,8 +5,10 @@ app = Flask(__name__) # Chargement de la configuration partagée (config.json à la racine du projet) -config_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'config.json') -with open(config_path, 'r') as f: +config_path = os.path.join( + os.path.dirname(os.path.abspath(__file__)), "..", "config.json" +) +with open(config_path, "r") as f: config = json.load(f) # ------------------------------------------------------- @@ -14,6 +16,7 @@ # le nombre d'errors, warnings et infos détectés. # ------------------------------------------------------- + def parse_logs(filepath): errors = [] warnings = [] @@ -36,11 +39,26 @@ def parse_logs(filepath): "warning_count": len(warnings), "info_count": len(infos), "errors": errors, - "warnings": warnings + "warnings": warnings, } @app.route("/api/logs", methods=["GET"]) +@app.route("/api/health", methods=["GET"]) +def health(): + return ( + jsonify( + { + "status": "ok", + "service": config["projet"], + "version": config.get("version", "1.0.0"), + "port": config["api"]["port"], + } + ), + 200, + ) + + def get_logs(): result = parse_logs(config["api"]["log_file"]) return jsonify(result), 200 From 8da8ed4a7879ec72019f24269954d0481964c48b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pr=C3=83=C2=A9nom=20Nom?= Date: Fri, 22 May 2026 11:03:39 +0200 Subject: [PATCH 3/8] ajout de la version sur le fichier config.json --- config.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config.json b/config.json index c62f739..414d98d 100644 --- a/config.json +++ b/config.json @@ -1,5 +1,6 @@ { "projet": "TP-Git-Collaboratif", + "version": "1.1.0", "promotion": "DevSecOps Azure — Simplon", "apprenants": [], "api": { @@ -9,3 +10,4 @@ "log_file": "server.log" } } + From b5181b1ccf0af310df5052d31aa4df92d201c832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pr=C3=83=C2=A9nom=20Nom?= Date: Fri, 22 May 2026 11:10:31 +0200 Subject: [PATCH 4/8] ajout d'une nouvelle route sur le app.py --- python-api/app.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/python-api/app.py b/python-api/app.py index bc7c4b5..0e4208d 100644 --- a/python-api/app.py +++ b/python-api/app.py @@ -41,6 +41,14 @@ def parse_logs(filepath): @app.route("/api/logs", methods=["GET"]) +@app.route("/api/health", methods=["GET"]) +def health(): + return jsonify({ + "status": "ok", + "service": config["projet"], + "version": config.get("version", "1.0.0"), + "port": config["api"]["port"] + }), 200 def get_logs(): result = parse_logs(config["api"]["log_file"]) return jsonify(result), 200 From 04115641281c0381fc6d207fa9794ee8f28a0eed Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Fri, 22 May 2026 11:26:45 +0200 Subject: [PATCH 5/8] Add commentary --- python-api/app.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python-api/app.py b/python-api/app.py index ca83129..242366b 100644 --- a/python-api/app.py +++ b/python-api/app.py @@ -44,6 +44,8 @@ def parse_logs(filepath): @app.route("/api/logs", methods=["GET"]) +# Health check endpoint — returns the current status of the API service, +# including the project name, version, and port loaded from config.json @app.route("/api/health", methods=["GET"]) def health(): return ( From 64a17889811540b1a85294cdd6dca28450700599 Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Fri, 22 May 2026 14:10:05 +0200 Subject: [PATCH 6/8] fix log route --- python-api/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python-api/app.py b/python-api/app.py index 242366b..64107d1 100644 --- a/python-api/app.py +++ b/python-api/app.py @@ -43,7 +43,6 @@ def parse_logs(filepath): } -@app.route("/api/logs", methods=["GET"]) # Health check endpoint — returns the current status of the API service, # including the project name, version, and port loaded from config.json @app.route("/api/health", methods=["GET"]) @@ -61,6 +60,7 @@ def health(): ) +@app.route("/api/logs", methods=["GET"]) def get_logs(): result = parse_logs(config["api"]["log_file"]) return jsonify(result), 200 From f0f8d7325d1efb410ae0b43c8b3cc8eb001feed6 Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Fri, 22 May 2026 14:15:43 +0200 Subject: [PATCH 7/8] fix log route --- python-api/app.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/python-api/app.py b/python-api/app.py index 67d70e1..1567288 100644 --- a/python-api/app.py +++ b/python-api/app.py @@ -60,15 +60,22 @@ def health(): ) -@app.route("/api/logs", methods=["GET"]) @app.route("/api/health", methods=["GET"]) def health(): - return jsonify({ - "status": "ok", - "service": config["projet"], - "version": config.get("version", "1.0.0"), - "port": config["api"]["port"] - }), 200 + return ( + jsonify( + { + "status": "ok", + "service": config["projet"], + "version": config.get("version", "1.0.0"), + "port": config["api"]["port"], + } + ), + 200, + ) + + +@app.route("/api/logs", methods=["GET"]) def get_logs(): result = parse_logs(config["api"]["log_file"]) return jsonify(result), 200 From 34bac1e37e9220f4efce080885dfc2002d13171a Mon Sep 17 00:00:00 2001 From: malikcherfi Date: Fri, 22 May 2026 14:21:15 +0200 Subject: [PATCH 8/8] remove duplicate function --- python-api/app.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/python-api/app.py b/python-api/app.py index 1567288..64107d1 100644 --- a/python-api/app.py +++ b/python-api/app.py @@ -60,21 +60,6 @@ def health(): ) -@app.route("/api/health", methods=["GET"]) -def health(): - return ( - jsonify( - { - "status": "ok", - "service": config["projet"], - "version": config.get("version", "1.0.0"), - "port": config["api"]["port"], - } - ), - 200, - ) - - @app.route("/api/logs", methods=["GET"]) def get_logs(): result = parse_logs(config["api"]["log_file"])