Introdução ao FastAPI
Matt Eckerle
Software and Data Engineering Leader
Protocolo HTTP - vários tipos de operações
Exemplo: https://www.google.com:80/search?q=fastapi
As partes-chave de uma requisição GET são:
www.google.com80 (padrão)/search?q=fastapiA aplicação FastAPI mais simples:
from fastapi import FastAPI# Instanciar o app app = FastAPI()# Tratar GET para a raiz @app.get("/") def root(): return {"message": "Hello World"}
Principais opções do cURL:
$ 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
Exemplo de uso:
$ curl http://localhost:8000
{"message":"Hello World"}
Novo endpoint:
@app.get("/hello")
def hello(name: str = "Alan"):
return {"message": f"Hello {name}"}
Nome ausente na requisição:

Nome na requisição:

Introdução ao FastAPI