KazeDevID commited on
Commit
fe25e4b
1 Parent(s): 66958a3

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # Membuat interface Gradio
14
+ iface = gr.Interface(
15
+ fn=get_waifu_image,
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()