File size: 522 Bytes
e189155
2937f6c
 
e189155
 
 
2937f6c
 
 
 
 
e189155
 
 
1175fd3
039467a
 
2937f6c
 
 
 
039467a
2937f6c
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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)}