<reponame>KiLJ4EdeN/fastapi_basics
from enum import Enum
import os
from fastapi import FastAPI


# create a enum class for the possible choices on the url path.
class ModelName(str, Enum):
    alexnet = "alexnet"
    resnet = "resnet"
    lenet = "lenet"


app = FastAPI()


# conventional end point with a "model_name" parameter to be passed.
# this time the parameter will be validated by the enum class.
# an error will be displayed if the passed value is not within the enum class.
@app.get("/models/{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"}


if __name__ == '__main__':
    print(f'INFO:     Starting the FASTAPI server...')
    print(f'INFO:     DOCS on: http://127.0.0.1:11111/docs')
    os.system(f"uvicorn {(__file__.split('/')[-1]).split('.')[0]}:app --host 127.0.0.1 --port 11111")

from enum import Enum
import os
from fastapi import FastAPI


# create a enum class for the possible choices on the url path.
class ModelName(str, Enum):
    alexnet = "alexnet"
    resnet = "resnet"
    lenet = "lenet"


app = FastAPI()


# conventional end point with a "model_name" parameter to be passed.
# this time the parameter will be validated by the enum class.
# an error will be displayed if the passed value is not within the enum class.
@app.get("/models/{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"}


if __name__ == '__main__':
    print(f'INFO:     Starting the FASTAPI server...')
    print(f'INFO:     DOCS on: http://127.0.0.1:11111/docs')
    os.system(f"uvicorn {(__file__.split('/')[-1]).split('.')[0]}:app --host 127.0.0.1 --port 11111")
# create a enum class for the possible choices on the url path. # conventional end point with a "model_name" parameter to be passed. # this time the parameter will be validated by the enum class. # an error will be displayed if the passed value is not within the enum class.