mirror of
https://github.com/fastapi/fastapi.git
synced 2025-12-31 10:10:51 -05:00
* Added response example; URL for quick access; typo fixes * Added line breaks for readability * Fix typo on redoc url * 📝 Update format, links, rewordings Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
24 lines
545 B
Python
24 lines
545 B
Python
from enum import Enum
|
|
|
|
from fastapi import FastAPI
|
|
|
|
|
|
class ModelName(str, Enum):
|
|
alexnet = "alexnet"
|
|
resnet = "resnet"
|
|
lenet = "lenet"
|
|
|
|
|
|
app = FastAPI()
|
|
|
|
|
|
@app.get("/model/{model_name}")
|
|
async def get_model(model_name: ModelName):
|
|
if model_name == 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"}
|