Spaces:
Running
Running
Upload main.py
Browse files
main.py
CHANGED
@@ -289,49 +289,36 @@ async def youtube_api(payload: YouTubeBase):
|
|
289 |
randydev={"error": f"An error occurred: {str(e)}"}
|
290 |
)
|
291 |
|
292 |
-
|
|
|
293 |
try:
|
294 |
-
image = Image.open(input)
|
295 |
-
buffer = io.BytesIO()
|
296 |
-
image.save(buffer, format='JPEG')
|
297 |
-
buffer.seek(0)
|
298 |
files = {
|
299 |
-
'image': ('toanime.jpg',
|
300 |
}
|
301 |
-
|
302 |
-
|
303 |
-
files=files,
|
304 |
-
headers={
|
305 |
-
'accept': 'application/json'
|
306 |
-
}
|
307 |
-
)
|
308 |
if response.status_code == 200:
|
309 |
data = response.json()
|
310 |
res = {
|
311 |
"image_data": data['result'],
|
312 |
"image_size": data['size']
|
313 |
}
|
314 |
-
return
|
|
|
|
|
|
|
315 |
else:
|
316 |
-
return
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
@app.get("/akeno/toanime", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
|
321 |
-
async def toanimes(link=None):
|
322 |
-
try:
|
323 |
-
response = await toanime(link)
|
324 |
-
url_image = response["image_data"]
|
325 |
-
return SuccessResponse(
|
326 |
-
status="True",
|
327 |
-
randydev={"url": url_image}
|
328 |
-
)
|
329 |
except Exception:
|
330 |
return SuccessResponse(
|
331 |
status="False",
|
332 |
randydev={"error": "Error during processing"}
|
333 |
)
|
334 |
|
|
|
335 |
async def api_tools_fix(name, ok, query):
|
336 |
url = f"https://tools.betabotz.eu.org/tools/{name}?{ok}={query}"
|
337 |
response = requests.get(url).json()
|
|
|
289 |
randydev={"error": f"An error occurred: {str(e)}"}
|
290 |
)
|
291 |
|
292 |
+
@app.get("/akeno/toanime", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
|
293 |
+
async def toanimes(file_path=None):
|
294 |
try:
|
|
|
|
|
|
|
|
|
295 |
files = {
|
296 |
+
'image': ('toanime.jpg', file_path, 'image/jpeg')
|
297 |
}
|
298 |
+
headers = {"accept": "application/json"}
|
299 |
+
response = requests.post("https://tools.betabotz.eu.org/ai/toanime", files=files, headers=headers)
|
|
|
|
|
|
|
|
|
|
|
300 |
if response.status_code == 200:
|
301 |
data = response.json()
|
302 |
res = {
|
303 |
"image_data": data['result'],
|
304 |
"image_size": data['size']
|
305 |
}
|
306 |
+
return SuccessResponse(
|
307 |
+
status="True",
|
308 |
+
randydev={"results": res}
|
309 |
+
)
|
310 |
else:
|
311 |
+
return SuccessResponse(
|
312 |
+
status="False",
|
313 |
+
randydev={"error": "Identifikasi Gagal"}
|
314 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
315 |
except Exception:
|
316 |
return SuccessResponse(
|
317 |
status="False",
|
318 |
randydev={"error": "Error during processing"}
|
319 |
)
|
320 |
|
321 |
+
|
322 |
async def api_tools_fix(name, ok, query):
|
323 |
url = f"https://tools.betabotz.eu.org/tools/{name}?{ok}={query}"
|
324 |
response = requests.get(url).json()
|