ZamaClinik / app.py
gregoiregllt's picture
go
bb598af
raw
history blame
1.01 kB
from fastapi import FastAPI, File, Form, UploadFile, HTTPException
from fastapi.responses import JSONResponse, Response
from utils import extract_json_from_images
import numpy as np
from pydantic import BaseModel
from pathlib import Path
import time
from typing import List, cast
# Load the FHE server
# FHE_SERVER = FHEModelServer(DEPLOYMENT_DIR)
class Symptoms(BaseModel):
user_symptoms: List[str]
app = FastAPI()
@app.post("/extract-json")
async def extract_json(files: List[UploadFile] = File(...)):
try:
# Read the uploaded images
uploaded_images = [file.file for file in files]
# Extract JSON from images
json_data = extract_json_from_images(uploaded_images)
# Close the file objects
for file in uploaded_images:
file.close()
return JSONResponse(content=json_data)
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))
@app.get("/")
def greet_json():
return {"Hello": "Zama!"}