mirror of
https://github.com/rjNemo/fastapi
synced 2026-06-06 02:26:46 +00: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>
23 lines
545 B
Python
23 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"}
|