Introduction à FastAPI
Matt Eckerle
Software and Data Engineering Leader
Protocole HTTP – plusieurs types d'opérations
Exemple : https://www.google.com:80/search?q=fastapi
Les éléments clés d'une requête GET :
www.google.com80 (par défaut)/search?q=fastapiL'application FastAPI la plus simple :
from fastapi import FastAPI# Instancier l'appli app = FastAPI()# Gérer les requêtes GET vers la racine @app.get("/") def root(): return {"message": "Hello World"}
Options cURL clés :
$ curl -h
Usage: curl [options...] <url>
-v, --verbose Make the operation more talkative
-H, --header <header/@file> Pass custom header(s) to server
-d, --data <data> HTTP POST data
Exemple d'usage :
$ curl http://localhost:8000
{"message":"Hello World"}
Nouvel point de terminaison :
@app.get("/hello")
def hello(name: str = "Alan"):
return {"message": f"Hello {name}"}
Nom absent de la requête :

Nom présent dans la requête :

Introduction à FastAPI