inoutro commited on
Commit
a44bcd2
ยท
1 Parent(s): fae013f

initial commit

Browse files
Files changed (2) hide show
  1. app.py +28 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+
4
+ # Sleeper API์—์„œ ๋ฆฌ๊ทธ ์ •๋ณด๋ฅผ ๊ฐ€์ ธ์˜ค๋Š” ํ•จ์ˆ˜
5
+ def get_league_info(league_id):
6
+ url = f"https://api.sleeper.app/v1/league/{league_id}"
7
+ response = requests.get(url)
8
+ if response.status_code == 200:
9
+ return response.json()
10
+ else:
11
+ return {"error": "๋ฆฌ๊ทธ ์ •๋ณด๋ฅผ ๊ฐ€์ ธ์˜ค๋Š” ๋ฐ ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค."}
12
+
13
+ # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์ •์˜
14
+ def display_league_info(league_id):
15
+ info = get_league_info(league_id)
16
+ return info
17
+
18
+ # Gradio ์ธํ„ฐํŽ˜์ด์Šค ์„ค์ •
19
+ iface = gr.Interface(
20
+ fn=display_league_info,
21
+ inputs=gr.inputs.Textbox(label="๋ฆฌ๊ทธ ID๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”"),
22
+ outputs="json",
23
+ title="ํŒํƒ€์ง€ NBA ๋ฆฌ๊ทธ ์ •๋ณด",
24
+ description="Sleeper API๋ฅผ ํ†ตํ•ด ์‹ค์‹œ๊ฐ„์œผ๋กœ ์—…๋ฐ์ดํŠธ๋˜๋Š” ํŒํƒ€์ง€ NBA ๋ฆฌ๊ทธ ์ •๋ณด๋ฅผ ํ™•์ธํ•˜์„ธ์š”."
25
+ )
26
+
27
+ if __name__ == "__main__":
28
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio
2
+ requests