Parcourir la source

#feat: changing result

main
LucasUnioIT il y a 6 mois
Parent
révision
dc4e542805
2 fichiers modifiés avec 12 ajouts et 5 suppressions
  1. BIN
      __pycache__/main.cpython-312.pyc
  2. +12
    -5
      main.py

BIN
__pycache__/main.cpython-312.pyc Voir le fichier


+ 12
- 5
main.py Voir le fichier

@@ -8,16 +8,23 @@ from solve_captcha import quebrar_captcha_base64
app = FastAPI()
class CaptchaRequest(BaseModel):
base64_string: str
captchafile: str
authtoken: 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")
expected_token = "j7MgdTy4LX05RpE1XY0ykLTexu9LuOE4zg5AEMNymL6LAgCUNN8JGjM5wu26FDGV4j0Xz3km8ra51c3ihToa3fj48XpcsWr45g043bLVQA1sTBkJP4j823DNX67mbjqNR8p117sU580153Id0IavORjkCXRP"
if request.authtoken != expected_token:
# Se o token não corresponder, retorne erro 401 Unauthorized
raise HTTPException(status_code=401, detail="Unauthorized")
if not request.captchafile:
raise HTTPException(status_code=400, detail="captchafile is required")
try:
resultado_captcha = quebrar_captcha_base64(request.base64_string)
return {"resultado": resultado_captcha}
resultado_captcha = quebrar_captcha_base64(request.captchafile)
return {"captcha": "", "text": resultado_captcha, "is_correct": True, "status": 200}
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))

Chargement…
Annuler
Enregistrer