CommencerCommencer gratuitement

Ajouter un endpoint simple de vérification d’état

Vous souhaitez ajouter à votre application un endpoint simple de vérification d’état (health check).

Cet exercice fait partie du cours

Déployer l’IA en production avec FastAPI

Afficher le cours

Instructions

  • Ajoutez un endpoint GET à l’emplacement habituel des vérifications d’état.
  • Retournez un status égal à "OK".

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

from fastapi import FastAPI

app = FastAPI()

# Create health check endpoint
@app.get("____")
async def get_health():
    # Return status OK
    return {"status": "____"}
Modifier et exécuter le code