pythonasyncioapiasyncfastapiframeworkjsonjson-schemaopenapiopenapi3pydanticpython-typespython3redocreststarletteswaggerswagger-uiuvicornweb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
546 B
23 lines
546 B
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"}
|
|
|