Semaine 11
This commit is contained in:
@@ -0,0 +1,96 @@
|
||||
# Exo 3.1 "API Flask" - BOICHÉ Gauvain
|
||||
|
||||
Je déclare n'avoir pas usé de l'IA. J'ai en revanche utilisé à foison la documentation du cours :
|
||||
|
||||
- https://github.com/Laudroid/Live-Python-Web/blob/main/3-1-3-Installation-de-Flask-et-cr%C3%A9ation-d.md
|
||||
- https://github.com/Laudroid/Live-Python-Web/blob/main/3-1-4-Routing%2C-vues%2C-r%C3%A9ponses-HTTP-(JSON).md
|
||||
- https://github.com/Laudroid/Live-Python-Web/blob/main/3-1-5-Cr%C3%A9ation-d'APIs-web-(GET%2C-POST%2C-PUT.md
|
||||
|
||||
Et la seule erreur que j'avais eu n'a pas nécessité d'IA non plus.
|
||||
|
||||
Ligne 34 : `@app.route('/api/equipments/<int:equipment_id>', methods=['GET'])`
|
||||
|
||||
> renvoyait une erreur type "TraceError callback" parce que le contenu était `@app.route('/api/equipments/<int:id_equipement>', methods=['GET'])`. Une harmonisation des noms de variables a fait l'affaire.
|
||||
|
||||
# Résultats
|
||||
|
||||
## Côté client
|
||||
```
|
||||
> curl -i http://127.0.0.1:5000/api/equipments
|
||||
HTTP/1.1 200 OK
|
||||
Server: Werkzeug/3.1.8 Python/3.14.6
|
||||
Date: Tue, 07 Jul 2026 08:40:08 GMT
|
||||
Content-Type: application/json
|
||||
Content-Length: 244
|
||||
Connection: close
|
||||
|
||||
{
|
||||
"equipments": [
|
||||
{
|
||||
"active": true,
|
||||
"hostname": "srv-web-01",
|
||||
"id": 1,
|
||||
"ip": "192.168.1.10"
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"hostname": "sw-access-02",
|
||||
"id": 2,
|
||||
"ip": "192.168.1.2"
|
||||
}
|
||||
]
|
||||
}
|
||||
> curl -i http://127.0.0.1:5000/api/equipments/2
|
||||
HTTP/1.1 200 OK
|
||||
Server: Werkzeug/3.1.8 Python/3.14.6
|
||||
Date: Tue, 07 Jul 2026 08:40:10 GMT
|
||||
Content-Type: application/json
|
||||
Content-Length: 85
|
||||
Connection: close
|
||||
|
||||
{
|
||||
"active": true,
|
||||
"hostname": "sw-access-02",
|
||||
"id": 2,
|
||||
"ip": "192.168.1.2"
|
||||
}
|
||||
> curl -i http://127.0.0.1:5000/api/equipments/25
|
||||
HTTP/1.1 404 NOT FOUND
|
||||
Server: Werkzeug/3.1.8 Python/3.14.6
|
||||
Date: Tue, 07 Jul 2026 08:43:01 GMT
|
||||
Content-Type: application/json
|
||||
Content-Length: 50
|
||||
Connection: close
|
||||
|
||||
{
|
||||
"erreur": "\u00c9quipement non trouv\u00e9"
|
||||
}
|
||||
(jour-02) PS D:\Users\GaWin\LiveCampus\Semaine_11\Jour_02>
|
||||
```
|
||||
|
||||
## Côté serveur
|
||||
```
|
||||
* Serving Flask app 'app'
|
||||
* Debug mode: on
|
||||
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
|
||||
* Running on http://127.0.0.1:5000
|
||||
Press CTRL+C to quit
|
||||
* Restarting with stat
|
||||
* Debugger is active!
|
||||
* Debugger PIN: 917-152-107
|
||||
127.0.0.1 - - [07/Jul/2026 10:40:08] "GET /api/equipments HTTP/1.1" 200 -
|
||||
127.0.0.1 - - [07/Jul/2026 10:40:10] "GET /api/equipments/2 HTTP/1.1" 200 -
|
||||
* Detected change in '.\app.py', reloading
|
||||
* Restarting with stat
|
||||
* Debugger is active!
|
||||
* Debugger PIN: 917-152-107
|
||||
127.0.0.1 - - [07/Jul/2026 10:43:01] "GET /api/equipments/25 HTTP/1.1" 404 -
|
||||
```
|
||||
|
||||
# Exo 3.2 "API CRUD" - BOICHÉ Gauvain
|
||||
|
||||
Je déclare n'avoir pas usé de l'IA là non plus. Toujours utilisé à foison la documentation du cours :
|
||||
|
||||
- https://github.com/Laudroid/Live-Python-Web/blob/main/3-1-3-Installation-de-Flask-et-cr%C3%A9ation-d.md
|
||||
- https://github.com/Laudroid/Live-Python-Web/blob/main/3-1-4-Routing%2C-vues%2C-r%C3%A9ponses-HTTP-(JSON).md
|
||||
- https://github.com/Laudroid/Live-Python-Web/blob/main/3-1-5-Cr%C3%A9ation-d'APIs-web-(GET%2C-POST%2C-PUT.md
|
||||
Reference in New Issue
Block a user