Spaces:
Running
Running
Sumit Kumar
Refactor captcha resolution endpoint to accept image_path directly and remove unused greeting endpoint
039467a
from fastapi import FastAPI | |
from captcha import resolve_captcha | |
from pydantic import BaseModel | |
app = FastAPI() | |
class Item(BaseModel): | |
image_path: str | |
def greet_json(): | |
return {"Hello": "World!"} | |
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)} | |