Update app.py
Browse files
app.py
CHANGED
@@ -1,24 +1,14 @@
|
|
1 |
import requests
|
2 |
-
import gradio as gr
|
3 |
|
4 |
def get_waifu_image():
|
5 |
try:
|
6 |
response = requests.get('https://api.waifu.pics/sfw/waifu')
|
7 |
-
response.raise_for_status()
|
8 |
-
image_url = response.json().get('url')
|
9 |
-
return {"url": image_url}
|
10 |
except Exception as e:
|
11 |
return {"error": str(e)}
|
12 |
|
13 |
-
#
|
14 |
-
|
15 |
-
|
16 |
-
inputs=[],
|
17 |
-
outputs="json",
|
18 |
-
title="Waifu Image Fetcher",
|
19 |
-
description="Mengambil gambar Waifu dan menampilkan URL dalam format JSON."
|
20 |
-
)
|
21 |
-
|
22 |
-
# Menjalankan aplikasi
|
23 |
-
if __name__ == "__main__":
|
24 |
-
iface.launch()
|
|
|
1 |
import requests
|
|
|
2 |
|
3 |
def get_waifu_image():
|
4 |
try:
|
5 |
response = requests.get('https://api.waifu.pics/sfw/waifu')
|
6 |
+
response.raise_for_status() # Memastikan permintaan berhasil
|
7 |
+
image_url = response.json().get('url') # Mengambil URL gambar
|
8 |
+
return {"url": image_url} # Mengembalikan hasil dalam format JSON
|
9 |
except Exception as e:
|
10 |
return {"error": str(e)}
|
11 |
|
12 |
+
# Menampilkan output langsung
|
13 |
+
output = get_waifu_image()
|
14 |
+
print(output)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|