Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,6 @@ import requests
|
|
5 |
from typing import List, Dict, Union
|
6 |
import concurrent.futures
|
7 |
import traceback
|
8 |
-
import base64
|
9 |
|
10 |
# 환경 변수에서 토큰 가져오기
|
11 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
@@ -41,12 +40,12 @@ def get_most_liked_spaces(limit: int = 100) -> Union[List[Dict], str]:
|
|
41 |
except ValueError as e:
|
42 |
return f"JSON decoding error: {str(e)}"
|
43 |
|
44 |
-
def capture_thumbnail(space_id: str) ->
|
45 |
screenshot_url = f"https://huggingface.co/spaces/{space_id}/thumbnail.png"
|
46 |
try:
|
47 |
response = requests.get(screenshot_url, headers=get_headers())
|
48 |
if response.status_code == 200:
|
49 |
-
return
|
50 |
except requests.RequestException:
|
51 |
pass
|
52 |
return None
|
@@ -153,9 +152,9 @@ def create_ui():
|
|
153 |
for space in formatted_spaces:
|
154 |
with gr.Row(elem_classes="space-row") as space_row:
|
155 |
if space['thumbnail']:
|
156 |
-
gr.Image(value=
|
157 |
else:
|
158 |
-
gr.Image(value="https://huggingface.co/front/assets/huggingface_logo-noborder.svg", show_label=False, elem_classes="thumbnail")
|
159 |
with gr.Column():
|
160 |
gr.Markdown(f"{space['name']} by {space['author']} (Likes: {space['likes']})", elem_classes="space-info")
|
161 |
button = gr.Button("클릭", elem_classes="minimal-button")
|
|
|
5 |
from typing import List, Dict, Union
|
6 |
import concurrent.futures
|
7 |
import traceback
|
|
|
8 |
|
9 |
# 환경 변수에서 토큰 가져오기
|
10 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
|
|
40 |
except ValueError as e:
|
41 |
return f"JSON decoding error: {str(e)}"
|
42 |
|
43 |
+
def capture_thumbnail(space_id: str) -> bytes:
|
44 |
screenshot_url = f"https://huggingface.co/spaces/{space_id}/thumbnail.png"
|
45 |
try:
|
46 |
response = requests.get(screenshot_url, headers=get_headers())
|
47 |
if response.status_code == 200:
|
48 |
+
return response.content
|
49 |
except requests.RequestException:
|
50 |
pass
|
51 |
return None
|
|
|
152 |
for space in formatted_spaces:
|
153 |
with gr.Row(elem_classes="space-row") as space_row:
|
154 |
if space['thumbnail']:
|
155 |
+
gr.Image(value=space['thumbnail'], shape=(100, 100), show_label=False, elem_classes="thumbnail")
|
156 |
else:
|
157 |
+
gr.Image(value="https://huggingface.co/front/assets/huggingface_logo-noborder.svg", shape=(100, 100), show_label=False, elem_classes="thumbnail")
|
158 |
with gr.Column():
|
159 |
gr.Markdown(f"{space['name']} by {space['author']} (Likes: {space['likes']})", elem_classes="space-info")
|
160 |
button = gr.Button("클릭", elem_classes="minimal-button")
|