Introductie tot FastAPI
Matt Eckerle
Software and Data Engineering Leader
HTTP-protocol: verschillende typen bewerkingen
Voorbeeld: https://www.google.com:80/search?q=fastapi
Belangrijke onderdelen van een GET-verzoek:
www.google.com80 (standaard)/search?q=fastapiDe simpelste FastAPI-app:
from fastapi import FastAPI# App aanmaken app = FastAPI()# GET-verzoeken naar root afhandelen @app.get("/") def root(): return {"message": "Hello World"}
Belangrijke cURL-opties:
$ 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
Voorbeeldgebruik:
$ curl http://localhost:8000
{"message":"Hello World"}
Nieuwe endpoint:
@app.get("/hello")
def hello(name: str = "Alan"):
return {"message": f"Hello {name}"}
Naam niet in verzoek:

Naam in verzoek:

Introductie tot FastAPI