from fastapi import FastAPI
from paddleocr import PaddleOCR
import psutil
import os
import uvicorn

PORT = 39127
app = FastAPI()

ocr = PaddleOCR()
@app.get("/")
async def root():
    return {"hello": "world"}

@app.post("/ocr")
async def run_ocr(data: dict):

    image = data["image"]

    result = ocr.ocr(image)
    result = ""
    return {
        "success": True,
        "result": result
    }





if __name__ == "__main__":
    #kill_port(PORT)
    uvicorn.run(
        app,
        host="127.0.0.1",
        port=PORT,
        log_level="error"
    )
