Spaces:
Running
Running
Upload main.py
Browse files
main.py
CHANGED
@@ -440,36 +440,35 @@ async def tebakgambar_answer():
|
|
440 |
randydev={"error": "Error fucking"}
|
441 |
)
|
442 |
|
443 |
-
@app.
|
444 |
async def toanimes(file_path=None):
|
445 |
try:
|
|
|
|
|
|
|
|
|
446 |
files = {
|
447 |
-
'image': ('toanime.jpg',
|
448 |
}
|
449 |
headers = {"accept": "application/json"}
|
450 |
response = requests.post("https://tools.betabotz.eu.org/ai/toanime", files=files, headers=headers)
|
451 |
-
if response.status_code
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
return SuccessResponse(
|
463 |
-
status="False",
|
464 |
-
randydev={"error": "Identifikasi Gagal"}
|
465 |
-
)
|
466 |
except Exception:
|
467 |
return SuccessResponse(
|
468 |
status="False",
|
469 |
randydev={"error": "Error during processing"}
|
470 |
)
|
471 |
|
472 |
-
|
473 |
async def api_tools_fix(name, ok, query):
|
474 |
url = f"https://tools.betabotz.eu.org/tools/{name}?{ok}={query}"
|
475 |
response = requests.get(url).json()
|
|
|
440 |
randydev={"error": "Error fucking"}
|
441 |
)
|
442 |
|
443 |
+
@app.post("/akeno/toanime", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
|
444 |
async def toanimes(file_path=None):
|
445 |
try:
|
446 |
+
image = Image.open(file_path)
|
447 |
+
buffer = io.BytesIO()
|
448 |
+
image.save(buffer, format='JPEG')
|
449 |
+
buffer.seek(0)
|
450 |
files = {
|
451 |
+
'image': ('toanime.jpg', buffer, 'image/jpeg')
|
452 |
}
|
453 |
headers = {"accept": "application/json"}
|
454 |
response = requests.post("https://tools.betabotz.eu.org/ai/toanime", files=files, headers=headers)
|
455 |
+
if response.status_code != 200:
|
456 |
+
return None
|
457 |
+
data = response.json()
|
458 |
+
res = {
|
459 |
+
"image_data": data['result'],
|
460 |
+
"image_size": data['size']
|
461 |
+
}
|
462 |
+
return SuccessResponse(
|
463 |
+
status="True",
|
464 |
+
randydev={"results": res}
|
465 |
+
)
|
|
|
|
|
|
|
|
|
466 |
except Exception:
|
467 |
return SuccessResponse(
|
468 |
status="False",
|
469 |
randydev={"error": "Error during processing"}
|
470 |
)
|
471 |
|
|
|
472 |
async def api_tools_fix(name, ok, query):
|
473 |
url = f"https://tools.betabotz.eu.org/tools/{name}?{ok}={query}"
|
474 |
response = requests.get(url).json()
|