From b84219fc29c1e4b26503571766ad27aeae847874 Mon Sep 17 00:00:00 2001 From: ororck Date: Thu, 21 May 2026 16:21:58 +0200 Subject: [PATCH 1/2] fix(python-node): correct 8 bugs in api and node client log analysis --- .gitignore | 7 +- config.json | 4 +- email-template.md | 75 ++++---- node-client/app.js | 6 +- node-client/package-lock.json | 346 ++++++++++++++++++++++++++++++++++ node-client/package.json | 4 +- python-api/app.py | 14 +- python-api/package-lock.json | 6 + python-api/requirements.txt | 4 +- 9 files changed, 410 insertions(+), 56 deletions(-) create mode 100644 node-client/package-lock.json create mode 100644 python-api/package-lock.json diff --git a/.gitignore b/.gitignore index 9a687c7..2ae4ac1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,8 @@ +# Node.js and Python build artifacts +node_modules/ +__pycache__/ +*.pyc + # Local .terraform directories .terraform/ @@ -43,4 +48,4 @@ terraform.rc # Uncomment the line below if you want to ignore planout files. # planout -.DS_Store \ No newline at end of file +.DS_Store diff --git a/config.json b/config.json index b18c09b..e04fd0a 100644 --- a/config.json +++ b/config.json @@ -3,9 +3,9 @@ "promotion": "DevSecOps Azure — Simplon", "apprenants": [], "api": { - "port": 50001, + "port": 5000, "host": "localhost", "route": "/api/logs", "log_file": "server.log" } -} +} \ No newline at end of file diff --git a/email-template.md b/email-template.md index dc7a939..05f3550 100644 --- a/email-template.md +++ b/email-template.md @@ -1,21 +1,20 @@ -# Template — Rapport de débogage par email - -> Complétez chaque section entre crochets [ ]. Supprimez les instructions en italique avant d'envoyer. +# Rapport de débogage par email --- **À :** responsable.technique@azuretech.fr -**De :** [votre.prenom.nom@azuretech.fr] -**Objet :** [À compléter — soyez précis et professionnel, ex: "Rapport de correction — scripts d'analyse de logs Azure"] -**Date :** [date du jour] +**De :** [saidi.mohamed.nom@azuretech.fr] +**Objet :** Rapport de correction — scripts d'analyse de logs Azure +**Date :** 21 mai 2026 --- -Bonjour [Prénom du responsable], +Bonjour, **1. Contexte** -[Décrivez en 2-3 phrases : quel projet, quels scripts étaient en erreur, dans quel environnement vous avez travaillé] +Dans le cadre du projet NexaCloud, deux scripts critiques avaient des erreurs suite à une mise à jour en production : `python-api/app.py` et `node-client/app.js`. +J'ai travaillé en local sur Windows avec Python 3.12 et Node.js 24, sur la branche `fix/mohamed-debug-python-node`. --- @@ -25,66 +24,64 @@ Bonjour [Prénom du responsable], | # | Fichier | Ligne | Type d'erreur | Description du problème | |---|---------|-------|---------------|--------------------------| -| 1 | | | | | -| 2 | | | | | -| 3 | | | | | -| 4 | | | | | -| 5 | | | | | +| 1 | `requirements.txt` | 2 | Nom de paquet incorrect | `flaskk` n'existe pas sur PyPI | +| 2 | `app.py` | 18 | SyntaxError | `:` manquant à la fin de `def parse_logs(filepath)` | +| 3 | `app.py` | ~30 | NameError | Variable `errors` utilisée à la place de `erreurs` dans `parse_logs` | +| 4 | `app.py` | 50 | NameError | Variable `log_file` non définie utilisée à la place de `"server.log"` | +| 5 | `config.json` | — | Mauvaise configuration | Port `50001` au lieu de `5000` | *Projet Node.js — `node-client/` :* | # | Fichier | Ligne | Type d'erreur | Description du problème | |---|---------|-------|---------------|--------------------------| -| 1 | | | | | -| 2 | | | | | -| 3 | | | | | +| 1 | `package.json` | — | Nom de paquet incorrect | `axioss` n'existe pas sur npm | +| 2 | `app.js` | 12 | MODULE_NOT_FOUND | `require('axioss')` — même faute de frappe que dans package.json | +| 3 | `app.js` | 21 | Mauvaise propriété axios | `response.body` n'existe pas dans axios, la bonne propriété est `response.data` | --- **3. Corrections apportées** -[Pour chaque bug, expliquez en une phrase ce que vous avez changé ET pourquoi c'est correct.] - -- Bug 1 : -- Bug 2 : -- Bug 3 : -- Bug 4 : -- Bug 5 : -- Bug 6 : -- Bug 7 : -- Bug 8 : +- Bug 1 : `requirements.txt` — corrigé `flaskk==3.0.0` en `flask==3.0.0` car le nom officiel du paquet sur PyPI est `flask`. +- Bug 2 : `app.py` ligne 18 — ajouté `:` en fin de `def parse_logs(filepath):` car toute définition de fonction Python requiert ça. +- Bug 3 : `app.py` — corrigé `errors` en `erreurs` pour correspondre au nom de variable déclaré en début de fonction. +- Bug 4 : `app.py` ligne 50 — remplacé la variable indéfinie `log_file` par la chaîne `"server.log"`, nom réel du fichier de logs dans le dossier. +- Bug 5 : `config.json` — corrigé le port `50001` en `5000`, valeur attendue par l'architecture du projet et par le client Node. +- Bug 6 : `package.json` — corrigé `"axioss"` en `"axios"` car c'est le nom exact du paquet HTTP sur npm. +- Bug 7 : `app.js` ligne 12 — corrigé `require('axioss')` en `require('axios')` pour correspondre au paquet installé. +- Bug 8 : `app.js` ligne 21 — remplacé `response.body` par `response.data` car dans axios, les données de la réponse serveur sont accessibles via `.data` (cf. documentation officielle axios-http.com/docs/res_schema). --- **4. Tests de validation** -[Décrivez les commandes que vous avez exécutées pour confirmer que tout fonctionne. -Incluez le résultat attendu vs le résultat obtenu.] +- Commande testée : `curl http://localhost:5000/api/logs` +- Résultat obtenu : JSON avec `error_count: 5`, `warning_count: 4`, `info_count: 10` +- Résultat attendu : identique +- Validation : ✅ -- Commande testée : -- Résultat obtenu : -- Résultat attendu : -- Validation : ✅ / ❌ +- Commande testée : `node app.js` +- Résultat obtenu : rapport complet affiché dans le terminal avec les 5 erreurs et 4 avertissements détaillés +- Résultat attendu : identique +- Validation : ✅ --- **5. Lien vers la Pull Request** -[Insérez ici l'URL complète de votre PR GitHub] +[À insérer après ouverture de la PR sur GitHub — étape 6 du TP] --- **6. Recommandations** -[Proposez 1 ou 2 bonnes pratiques à adopter pour éviter ce type de bug à l'avenir.] - -- -- +- Mettre en place un pipeline CI (GitHub Actions) qui installe les dépendances et vérifie la syntaxe à chaque push — cela aurait détecté les bugs `flaskk` et `axioss` immédiatement sans avoir à lancer les scripts manuellement. +- Ne jamais hardcoder les noms de fichiers ou de variables sans les tester : utiliser des variables d'environnement ou un fichier de config versionné et validé pour éviter les incohérences de port ou de chemin. --- Cordialement, -[Prénom Nom] +[Mohamed Saidi] Développeur DevSecOps — Promotion Azure, Simplon -[votre.email@azuretech.fr] +[saidi.mohamed.nom@azuretech.fr] diff --git a/node-client/app.js b/node-client/app.js index 6fbf5cf..fad8aa5 100644 --- a/node-client/app.js +++ b/node-client/app.js @@ -9,7 +9,7 @@ const config = require(path.join(__dirname, '..', 'config.json')); const API_URL = `http://${config.api.host}:${config.api.port}${config.api.route}`; // BUG 6 — Le nom du module importé ici est incorrect -const axioss = require('axioss'); +const axioss = require('axios'); async function getLogs() { try { @@ -17,8 +17,8 @@ async function getLogs() { // BUG 7 — La propriété pour accéder au corps de la réponse avec axios // ne s'appelle pas .body — cherchez dans la doc axios comment - // accéder aux données de la réponse - const data = response.body; + // accéder aux données de la réponse body -> data + const data = response.data; console.log('\n========================================'); console.log(' RAPPORT D\'ANALYSE DES LOGS AZURE '); diff --git a/node-client/package-lock.json b/node-client/package-lock.json new file mode 100644 index 0000000..6fc99fe --- /dev/null +++ b/node-client/package-lock.json @@ -0,0 +1,346 @@ +{ + "name": "log-analyser-client", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "log-analyser-client", + "version": "1.0.0", + "dependencies": { + "axios": "^1.6.0" + } + }, + "node_modules/agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "license": "MIT", + "dependencies": { + "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, + "node_modules/axios": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.16.1.tgz", + "integrity": "sha512-caYkukvroVPO8KrzuJEb50Hm07KwfBZPEC3VeFHTsqWHvKTsy54hjJz9BS/cdaypROE2rH6xvm9mHX4fgWkr3A==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.16.0", + "form-data": "^4.0.5", + "https-proxy-agent": "^5.0.1", + "proxy-from-env": "^2.1.0" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/follow-redirects": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz", + "integrity": "sha512-y5rN/uOsadFT/JfYwhxRS5R7Qce+g3zG97+JrtFZlC9klX/W5hD7iiLzScI4nZqUS7DNUdhPgw4xI8W2LuXlUw==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz", + "integrity": "sha512-8RipRLol37bNs2bhoV67fiTEvdTrbMUYcFTiy3+wuuOnUog2QBHCZWXDRijWQfAkhBj2Uf5UnVaiWwA5vdd82w==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.2", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.3.tgz", + "integrity": "sha512-ej4AhfhfL2Q2zpMmLo7U1Uv9+PyhIZpgQLGT1F9miIGmiCJIoCgSmczFdrc97mWT4kVY72KA+WnnhJ5pghSvSg==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "license": "MIT", + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/proxy-from-env": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-2.1.0.tgz", + "integrity": "sha512-cJ+oHTW1VAEa8cJslgmUZrc+sjRKgAKl3Zyse6+PV38hZe/V6Z14TbCuXcan9F9ghlz4QrFr2c92TNF82UkYHA==", + "license": "MIT", + "engines": { + "node": ">=10" + } + } + } +} diff --git a/node-client/package.json b/node-client/package.json index ea94ac5..cbe3266 100644 --- a/node-client/package.json +++ b/node-client/package.json @@ -7,6 +7,6 @@ "start": "node app.js" }, "dependencies": { - "axioss": "^1.6.0" + "axios": "^1.6.0" } -} +} \ No newline at end of file diff --git a/python-api/app.py b/python-api/app.py index 2505f77..8369e11 100644 --- a/python-api/app.py +++ b/python-api/app.py @@ -14,8 +14,8 @@ # le nombre d'erreurs, warnings et infos détectés. # ------------------------------------------------------- -# BUG 2 — Il manque un caractère essentiel à la fin de cette ligne -def parse_logs(filepath) +# BUG 2 — Il manque un caractère essentiel à la fin de cette ligne. add : +def parse_logs(filepath): erreurs = [] warnings = [] infos = [] @@ -26,9 +26,9 @@ def parse_logs(filepath) if not line: continue # BUG 3 — Le nom de la variable utilisée ici ne correspond pas - # à celle déclarée plus haut dans cette fonction + # à celle déclarée plus haut dans cette fonction. errors -> erreurs if "ERROR" in line: - errors.append(line) + erreurs.append(line) elif "WARNING" in line: warnings.append(line) elif "INFO" in line: @@ -46,12 +46,12 @@ def parse_logs(filepath) @app.route("/api/logs", methods=["GET"]) def get_logs(): # BUG 4 — La variable passée en argument n'est définie nulle part - # Quel fichier de logs doit-on analyser ? - result = parse_logs(log_file) + # Quel fichier de logs doit-on analyser ? server.log + result = parse_logs("server.log") return jsonify(result), 200 if __name__ == "__main__": # Le port est chargé depuis config.json - # BUG 5 — Le port est défini dans config.json — est-il correct ? + # BUG 5 — Le port est défini dans config.json — est-il correct ? 50001 -> 5000 app.run(debug=True, port=config["api"]["port"]) diff --git a/python-api/package-lock.json b/python-api/package-lock.json new file mode 100644 index 0000000..ea46d3a --- /dev/null +++ b/python-api/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "python-api", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/python-api/requirements.txt b/python-api/requirements.txt index b6f3435..5dbd6e6 100644 --- a/python-api/requirements.txt +++ b/python-api/requirements.txt @@ -1,2 +1,2 @@ -# BUG 1 — Le nom du paquet ci-dessous est incorrect. Lisez attentivement. -flaskk==3.0.0 +# BUG 1 — Le nom du paquet ci-dessous est incorrect. Lisez attentivement. flaskk -> flask +flask==3.0.0 From c338eb252e14c4be34ef30ced82e23dd495e5058 Mon Sep 17 00:00:00 2001 From: ororck Date: Fri, 22 May 2026 12:53:17 +0200 Subject: [PATCH 2/2] fix(python-node): use config for log_file path and rename axioss to axios --- node-client/app.js | 4 ++-- python-api/app.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/node-client/app.js b/node-client/app.js index fad8aa5..9716a58 100644 --- a/node-client/app.js +++ b/node-client/app.js @@ -9,11 +9,11 @@ const config = require(path.join(__dirname, '..', 'config.json')); const API_URL = `http://${config.api.host}:${config.api.port}${config.api.route}`; // BUG 6 — Le nom du module importé ici est incorrect -const axioss = require('axios'); +const axios = require('axios'); async function getLogs() { try { - const response = await axioss.get(API_URL); + const response = await axios.get(API_URL); // BUG 7 — La propriété pour accéder au corps de la réponse avec axios // ne s'appelle pas .body — cherchez dans la doc axios comment diff --git a/python-api/app.py b/python-api/app.py index 8369e11..3f6b904 100644 --- a/python-api/app.py +++ b/python-api/app.py @@ -47,7 +47,7 @@ def parse_logs(filepath): def get_logs(): # BUG 4 — La variable passée en argument n'est définie nulle part # Quel fichier de logs doit-on analyser ? server.log - result = parse_logs("server.log") + result = parse_logs(config["api"]["log_file"]) return jsonify(result), 200