Skip to content

aaben40/TP_Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mini-Projet Python API

Installation et utilisation

1. Télécharger le projet

# Via Git
git clone https://github.com/aaben40/TP_Python.git
cd TP_Python

# Ou télécharger le ZIP depuis GitHub et extraire

2. Installer les dépendances

pip install -r requirements.txt

3. Utilisation

# Test avec l'API DummyJSON (succès)
python main.py --protocol https --hostname dummyjson.com --uri /products --threshold 10

# Test avec timeout (échec volontaire)
python main.py --protocol https --hostname google.fr:9443 --uri / --threshold 5

4. Lancer les tests

python test/test_api.py

Paramètres

  • --protocol : http ou https
  • --hostname : nom d'hôte (ex: dummyjson.com)
  • --uri : URI de la ressource (ex: /products)
  • --threshold : seuil de timeout en secondes

Structure

TP_Python/
├── main.py              # Point d'entrée principal
├── requirements.txt     # Dépendances Python
├── src/
│   ├── api.py          # Fonctions HTTP et formatage URL
│   ├── cli.py          # Gestion des arguments CLI
│   └── exceptions.py   # Exception personnalisée
└── test/
    └── test_api.py     # Tests unitaires

Exemples

# API publique (succès attendu)
python main.py --protocol https --hostname httpbin.org --uri /get --threshold 5

# Serveur inaccessible (timeout attendu)
python main.py --protocol https --hostname example.com:9999 --uri / --threshold 3

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages