Spaces:
Running
Running
initial commit
Browse files- app.py +28 -0
- 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
|