Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -5,6 +5,7 @@ import requests
|
|
5 |
from typing import List, Dict, Union
|
6 |
import concurrent.futures
|
7 |
import traceback
|
|
|
8 |
|
9 |
# 환경 변수에서 토큰 가져오기
|
10 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
@@ -45,7 +46,7 @@ def capture_thumbnail(space_id: str) -> str:
|
|
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
|
@@ -119,9 +120,9 @@ def create_ui():
|
|
119 |
margin-bottom: 5px !important;
|
120 |
}
|
121 |
.thumbnail {
|
122 |
-
|
123 |
-
|
124 |
-
object-fit:
|
125 |
}
|
126 |
"""
|
127 |
|
@@ -149,7 +150,7 @@ def create_ui():
|
|
149 |
for space in formatted_spaces:
|
150 |
with gr.Row(elem_classes="space-row") as space_row:
|
151 |
if space['thumbnail']:
|
152 |
-
gr.Image(value=space['thumbnail'], show_label=False, elem_classes="thumbnail")
|
153 |
else:
|
154 |
gr.Markdown("No thumbnail")
|
155 |
with gr.Column():
|
|
|
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")
|
|
|
46 |
try:
|
47 |
response = requests.get(screenshot_url, headers=get_headers())
|
48 |
if response.status_code == 200:
|
49 |
+
return base64.b64encode(response.content).decode('utf-8')
|
50 |
except requests.RequestException:
|
51 |
pass
|
52 |
return None
|
|
|
120 |
margin-bottom: 5px !important;
|
121 |
}
|
122 |
.thumbnail {
|
123 |
+
width: 100px;
|
124 |
+
height: 100px;
|
125 |
+
object-fit: cover;
|
126 |
}
|
127 |
"""
|
128 |
|
|
|
150 |
for space in formatted_spaces:
|
151 |
with gr.Row(elem_classes="space-row") as space_row:
|
152 |
if space['thumbnail']:
|
153 |
+
gr.Image(value=f"data:image/png;base64,{space['thumbnail']}", show_label=False, elem_classes="thumbnail")
|
154 |
else:
|
155 |
gr.Markdown("No thumbnail")
|
156 |
with gr.Column():
|