mirror of
https://github.com/fastapi/fastapi.git
synced 2026-02-15 08:41:07 -05:00
📝 Update source examples and docs from Python 3.9 to 3.10
This commit is contained in:
23
docs_src/path_params/tutorial005_py310.py
Normal file
23
docs_src/path_params/tutorial005_py310.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from enum import Enum
|
||||
|
||||
from fastapi import FastAPI
|
||||
|
||||
|
||||
class ModelName(str, Enum):
|
||||
alexnet = "alexnet"
|
||||
resnet = "resnet"
|
||||
lenet = "lenet"
|
||||
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
@app.get("/models/{model_name}")
|
||||
async def get_model(model_name: ModelName):
|
||||
if model_name is ModelName.alexnet:
|
||||
return {"model_name": model_name, "message": "Deep Learning FTW!"}
|
||||
|
||||
if model_name.value == "lenet":
|
||||
return {"model_name": model_name, "message": "LeCNN all the images"}
|
||||
|
||||
return {"model_name": model_name, "message": "Have some residuals"}
|
||||
Reference in New Issue
Block a user