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