Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ import plotly.graph_objects as go
|
|
5 |
from datetime import datetime
|
6 |
import os
|
7 |
|
8 |
-
HF_TOKEN = os.getenv(
|
9 |
|
10 |
# ๊ด์ฌ ์คํ์ด์ค URL ๋ฆฌ์คํธ์ ์ ๋ณด
|
11 |
target_spaces = {
|
@@ -44,18 +44,28 @@ target_spaces = {
|
|
44 |
|
45 |
def get_trending_spaces():
|
46 |
try:
|
47 |
-
|
|
|
|
|
48 |
headers = {
|
49 |
'Authorization': f'Bearer {HF_TOKEN}',
|
50 |
'Accept': 'application/json'
|
51 |
}
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
if response.status_code == 200:
|
55 |
return response.json()
|
56 |
else:
|
57 |
print(f"API ์์ฒญ ์คํจ: {response.status_code}")
|
58 |
print(f"Response: {response.text}")
|
|
|
|
|
59 |
return None
|
60 |
except Exception as e:
|
61 |
print(f"API ํธ์ถ ์ค ์๋ฌ ๋ฐ์: {str(e)}")
|
@@ -235,4 +245,10 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
235 |
df_output.value = initial_df
|
236 |
|
237 |
# Gradio ์ฑ ์คํ
|
238 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
from datetime import datetime
|
6 |
import os
|
7 |
|
8 |
+
HF_TOKEN = os.getenv("HF_TOKEN")
|
9 |
|
10 |
# ๊ด์ฌ ์คํ์ด์ค URL ๋ฆฌ์คํธ์ ์ ๋ณด
|
11 |
target_spaces = {
|
|
|
44 |
|
45 |
def get_trending_spaces():
|
46 |
try:
|
47 |
+
# API ์๋ํฌ์ธํธ ์์
|
48 |
+
url = "https://huggingface.co/api/spaces?sort=trending" # ์์ ๋ URL
|
49 |
+
|
50 |
headers = {
|
51 |
'Authorization': f'Bearer {HF_TOKEN}',
|
52 |
'Accept': 'application/json'
|
53 |
}
|
54 |
+
|
55 |
+
params = {
|
56 |
+
'limit': 1000, # ๋ ๋ง์ ๊ฒฐ๊ณผ๋ฅผ ๊ฐ์ ธ์ค๊ธฐ ์ํด limit ์ฆ๊ฐ
|
57 |
+
'full': 'true'
|
58 |
+
}
|
59 |
+
|
60 |
+
response = requests.get(url, headers=headers, params=params)
|
61 |
|
62 |
if response.status_code == 200:
|
63 |
return response.json()
|
64 |
else:
|
65 |
print(f"API ์์ฒญ ์คํจ: {response.status_code}")
|
66 |
print(f"Response: {response.text}")
|
67 |
+
print(f"URL: {url}")
|
68 |
+
print(f"Headers: {headers}")
|
69 |
return None
|
70 |
except Exception as e:
|
71 |
print(f"API ํธ์ถ ์ค ์๋ฌ ๋ฐ์: {str(e)}")
|
|
|
245 |
df_output.value = initial_df
|
246 |
|
247 |
# Gradio ์ฑ ์คํ
|
248 |
+
if __name__ == "__main__":
|
249 |
+
demo.launch(
|
250 |
+
server_name="0.0.0.0",
|
251 |
+
server_port=7860,
|
252 |
+
share=False, # True๋ก ์ค์ ํ๋ฉด ๊ณต๊ฐ ๋งํฌ ์์ฑ
|
253 |
+
debug=True
|
254 |
+
)
|