git clone https://github.com/brandgit/TP_API1.git
cd data-integration2python -m venv env
source env/bin/activate # Sur macOS/Linux
# ou
env\Scripts\activate # Sur Windowspip install -r requirements.txtpython manage.py makemigrations
python manage.py migratepython manage.py createsuperuserLe projet utilise une configuration Django standard avec :
- Base de données SQLite (fichier
db.sqlite3) - Debug activé en mode développement
- Django REST Framework pour les API
# Activer l'environnement virtuel
source env/bin/activate
# Démarrer le serveur de développement
python manage.py runserverL'application sera accessible sur : http://localhost:8000
Accédez à l'interface d'administration Django : http://localhost:8000/admin
| Méthode | Endpoint | Description |
|---|---|---|
GET |
/api/test_json_view/ |
Test simple retournant du JSON |
POST |
/api/test_post_view/ |
Test d'endpoint POST |
GET |
/api/products/ |
Liste paginée des produits (3 par page) |
GET |
/api/products/expensive/ |
Produit le plus cher |
POST |
/api/products/create/ |
Créer un nouveau produit |
PUT |
/api/products/<id>/update/ |
Mettre à jour un produit |
curl -X POST http://localhost:8000/api/products/create/ \
-H "Content-Type: application/json" \
-d '{
"name": "iPhone 15",
"price": 999.99,
"description": "Dernier iPhone d'Apple"
}'curl http://localhost:8000/api/products/curl -X PUT http://localhost:8000/api/products/1/update/ \
-H "Content-Type: application/json" \
-d '{
"name": "iPhone 15 Pro",
"price": 1199.99,
"description": "iPhone 15 Pro avec fonctionnalités avancées"
}'# Construire et démarrer les conteneurs
docker-compose up --build
# Démarrer en arrière-plan
docker-compose up -d