# app.py from fastapi import FastAPI, File, UploadFile from fastapi.middleware.cors import CORSMiddleware from predict import read_image, transformacao app = FastAPI() # Add CORS middleware to allow requests from any origin (for development) app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_methods=["*"], allow_headers=["*"], ) @app.get("/") async def root(): return {"message": "Welcome to the medicinal plants image detection API!"} @app.post("/uploadfile/") async def create_upload_file(file: UploadFile = File(...)): contents = await file.read() # read image imagem = read_image(contents) # transform and prediction prediction = transformacao(imagem) return prediction