Spaces:
Running
Running
Update tools.py
Browse files
tools.py
CHANGED
@@ -74,12 +74,16 @@ async def toanime(input):
|
|
74 |
return 'Identifikasi Gagal'
|
75 |
|
76 |
@router.post("/akeno/toanime", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
|
77 |
-
async def
|
78 |
file: UploadFile = File(...),
|
79 |
-
api_key:
|
80 |
):
|
81 |
-
|
82 |
-
|
|
|
|
|
|
|
|
|
83 |
try:
|
84 |
response = await toanime(file_path)
|
85 |
url_image = response["image_data"]
|
@@ -87,11 +91,14 @@ async def toanime(
|
|
87 |
status="True",
|
88 |
randydev={"url": url_image}
|
89 |
)
|
90 |
-
except:
|
91 |
return SuccessResponse(
|
92 |
status="False",
|
93 |
-
randydev={"error": "Error
|
94 |
)
|
|
|
|
|
|
|
95 |
|
96 |
@router.post("/akeno/xnxxsearch", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
|
97 |
async def xnxx_search(
|
|
|
74 |
return 'Identifikasi Gagal'
|
75 |
|
76 |
@router.post("/akeno/toanime", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
|
77 |
+
async def toanime_endpoint(
|
78 |
file: UploadFile = File(...),
|
79 |
+
api_key: str = Depends(validate_api_key)
|
80 |
):
|
81 |
+
file_path = f"./uploads/{file.filename}"
|
82 |
+
try:
|
83 |
+
with open(file_path, "wb") as f:
|
84 |
+
f.write(await file.read())
|
85 |
+
except Exception as e:
|
86 |
+
raise HTTPException(status_code=500, detail="Failed to save file")
|
87 |
try:
|
88 |
response = await toanime(file_path)
|
89 |
url_image = response["image_data"]
|
|
|
91 |
status="True",
|
92 |
randydev={"url": url_image}
|
93 |
)
|
94 |
+
except Exception:
|
95 |
return SuccessResponse(
|
96 |
status="False",
|
97 |
+
randydev={"error": "Error during processing"}
|
98 |
)
|
99 |
+
finally:
|
100 |
+
if os.path.exists(file_path):
|
101 |
+
os.remove(file_path)
|
102 |
|
103 |
@router.post("/akeno/xnxxsearch", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
|
104 |
async def xnxx_search(
|