captcha-ocr / app.py
Sumit Kumar
Refactor captcha resolution endpoint to accept image_path directly and remove unused greeting endpoint
039467a
raw
history blame contribute delete
522 Bytes
from fastapi import FastAPI
from captcha import resolve_captcha
from pydantic import BaseModel
app = FastAPI()
class Item(BaseModel):
image_path: str
@app.get("/")
def greet_json():
return {"Hello": "World!"}
@app.get("/resolve_captcha")
def decode_captcha(image_path: str):
"""
Decode the captcha image and return the text.
"""
try:
result = resolve_captcha(image_path)
return {"captcha_text": result}
except Exception as e:
return {"error": str(e)}