Coverage for docs_src/path_params/tutorial005.py: 100%
14 statements
« prev ^ index » next coverage.py v7.6.1, created at 2025-05-05 00:03 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2025-05-05 00:03 +0000
1from enum import Enum 1abcdef
3from fastapi import FastAPI 1abcdef
6class ModelName(str, Enum): 1abcdef
7 alexnet = "alexnet" 1abcdef
8 resnet = "resnet" 1abcdef
9 lenet = "lenet" 1abcdef
12app = FastAPI() 1abcdef
15@app.get("/models/{model_name}") 1abcdef
16async def get_model(model_name: ModelName): 1abcdef
17 if model_name is ModelName.alexnet: 1sghtijuklvmnwopxqr
18 return {"model_name": model_name, "message": "Deep Learning FTW!"} 1stuvwx
20 if model_name.value == "lenet": 1ghijklmnopqr
21 return {"model_name": model_name, "message": "LeCNN all the images"} 1gikmoq
23 return {"model_name": model_name, "message": "Have some residuals"} 1hjlnpr