from fastapi import FastAPI, HTTPException from pydantic import BaseModel from typing import Optional # Suponha que quebrar_captcha_base64 está definido em outro módulo ou arquivo from solve_captcha import quebrar_captcha_base64 app = FastAPI() class CaptchaRequest(BaseModel): base64_string: str @app.post("/solve_captcha/") async def solve_captcha(request: CaptchaRequest): if not request.base64_string: raise HTTPException(status_code=400, detail="base64_string is required") try: resultado_captcha = quebrar_captcha_base64(request.base64_string) return {"resultado": resultado_captcha} except Exception as e: raise HTTPException(status_code=500, detail=str(e))