Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -180,7 +180,109 @@ def get_space_card(space, index):
|
|
180 |
</div>
|
181 |
"""
|
182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
def get_user_spaces():
|
|
|
184 |
url = f"https://huggingface.co/api/spaces?author={USERNAME}&limit=500"
|
185 |
headers = {
|
186 |
"Accept": "application/json",
|
@@ -188,14 +290,9 @@ def get_user_spaces():
|
|
188 |
}
|
189 |
|
190 |
try:
|
|
|
191 |
response = requests.get(url, headers=headers)
|
192 |
-
|
193 |
-
print(f"Response length: {len(response.json()) if response.status_code == 200 else 'N/A'}")
|
194 |
-
|
195 |
-
if response.status_code != 200:
|
196 |
-
return f"Error: Failed to fetch spaces (Status Code: {response.status_code})"
|
197 |
-
|
198 |
-
spaces_data = response.json()
|
199 |
|
200 |
# ์ ์ธํ ์คํ์ด์ค ํํฐ๋ง
|
201 |
user_spaces = [
|
@@ -203,16 +300,8 @@ def get_user_spaces():
|
|
203 |
if not should_exclude_space(space.get('id', '').split('/')[-1])
|
204 |
]
|
205 |
|
206 |
-
|
207 |
-
|
208 |
-
<div style='padding: 20px; text-align: center; color: #666;'>
|
209 |
-
<h2>No public Spaces found for user: {USERNAME}</h2>
|
210 |
-
<p>Try visiting: <a href='https://huggingface.co/{USERNAME}' target='_blank'>
|
211 |
-
https://huggingface.co/{USERNAME}</a></p>
|
212 |
-
</div>
|
213 |
-
"""
|
214 |
-
|
215 |
-
user_spaces.sort(key=lambda x: x.get('likes', 0), reverse=True)
|
216 |
|
217 |
html_content = f"""
|
218 |
<div style='padding: 20px; background-color: #f5f5f5;'>
|
@@ -221,25 +310,29 @@ def get_user_spaces():
|
|
221 |
<p style='color: #666; margin: 0 0 15px 0; font-size: 0.9em;'>
|
222 |
ํ๋กฌํํธ๋ง์ผ๋ก ๋๋ง์ ์น์๋น์ค๋ฅผ ์ฆ์ ์์ฑํ๋ MOUSE
|
223 |
<a href='https://openfree-mouse.hf.space' target='_blank'
|
224 |
-
style='color: #0084ff; text-decoration: none;
|
225 |
-
onmouseover='this.style.color="#00a3ff"'
|
226 |
-
onmouseout='this.style.color="#0084ff"'>
|
227 |
https://openfree-mouse.hf.space
|
228 |
</a>
|
229 |
</p>
|
230 |
-
<p style='color: #666; margin: 0;'>
|
|
|
|
|
231 |
</div>
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
'>
|
237 |
{"".join(get_space_card(space, idx) for idx, space in enumerate(user_spaces))}
|
238 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
</div>
|
240 |
"""
|
241 |
|
242 |
-
|
243 |
return html_content
|
244 |
|
245 |
except Exception as e:
|
|
|
180 |
</div>
|
181 |
"""
|
182 |
|
183 |
+
def get_vercel_deployments():
|
184 |
+
"""Vercel API๋ฅผ ํตํด ๋ฐฐํฌ๋ ์๋น์ค ์ ๋ณด ๊ฐ์ ธ์ค๊ธฐ"""
|
185 |
+
token = "A8IFZmgW2cqA4yUNlLPnci0N"
|
186 |
+
url = "https://api.vercel.com/v6/deployments"
|
187 |
+
|
188 |
+
headers = {
|
189 |
+
"Authorization": f"Bearer {token}",
|
190 |
+
"Content-Type": "application/json"
|
191 |
+
}
|
192 |
+
|
193 |
+
try:
|
194 |
+
response = requests.get(url, headers=headers)
|
195 |
+
if response.status_code != 200:
|
196 |
+
print(f"Vercel API Error: {response.text}")
|
197 |
+
return []
|
198 |
+
|
199 |
+
deployments = response.json().get('deployments', [])
|
200 |
+
|
201 |
+
# ์ํ๊ฐ 'READY'์ด๊ณ 'url'์ด ์๋ ๋ฐฐํฌ๋ง ํํฐ๋ง
|
202 |
+
active_deployments = [
|
203 |
+
dep for dep in deployments
|
204 |
+
if dep.get('state') == 'READY' and dep.get('url')
|
205 |
+
]
|
206 |
+
|
207 |
+
return active_deployments
|
208 |
+
except Exception as e:
|
209 |
+
print(f"Error fetching Vercel deployments: {str(e)}")
|
210 |
+
return []
|
211 |
+
|
212 |
+
def get_vercel_card(deployment, index):
|
213 |
+
"""Generate HTML card for a Vercel deployment"""
|
214 |
+
url = deployment.get('url', '')
|
215 |
+
created = format_timestamp(deployment.get('created'))
|
216 |
+
name = deployment.get('name', 'Unnamed Project')
|
217 |
+
state = deployment.get('state', 'N/A')
|
218 |
+
|
219 |
+
bg_color = get_pastel_color(index + 20) # ๊ธฐ์กด ์์๊ณผ ๊ฒน์น์ง ์๋๋ก ์ธ๋ฑ์ค ์กฐ์
|
220 |
+
|
221 |
+
# ๋๋ค ์ด๋ชจ์ง ์ ํ
|
222 |
+
tech_emojis = ['โก', '๐', '๐', 'โจ', '๐ซ', '๐ฅ', '๐', '๐ฏ', '๐จ', '๐ฎ']
|
223 |
+
random_emojis = random.sample(tech_emojis, 3)
|
224 |
+
|
225 |
+
return f"""
|
226 |
+
<div style='border: none;
|
227 |
+
padding: 25px;
|
228 |
+
margin: 15px;
|
229 |
+
border-radius: 20px;
|
230 |
+
background-color: {bg_color};
|
231 |
+
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
|
232 |
+
transition: all 0.3s ease-in-out;
|
233 |
+
position: relative;
|
234 |
+
overflow: hidden;'
|
235 |
+
onmouseover='this.style.transform="translateY(-5px) scale(1.02)"; this.style.boxShadow="0 8px 25px rgba(0,0,0,0.15)"'
|
236 |
+
onmouseout='this.style.transform="translateY(0) scale(1)"; this.style.boxShadow="0 4px 15px rgba(0,0,0,0.1)"'>
|
237 |
+
<div style='position: absolute; top: -15px; right: -15px; font-size: 100px; opacity: 0.1;'>
|
238 |
+
{random_emojis[0]}
|
239 |
+
</div>
|
240 |
+
<h3 style='color: #2d2d2d;
|
241 |
+
margin: 0 0 20px 0;
|
242 |
+
font-size: 1.4em;
|
243 |
+
display: flex;
|
244 |
+
align-items: center;
|
245 |
+
gap: 10px;'>
|
246 |
+
<span style='font-size: 1.3em'>{random_emojis[1]}</span>
|
247 |
+
<a href='https://{url}' target='_blank'
|
248 |
+
style='text-decoration: none; color: #2d2d2d;'>
|
249 |
+
{name}
|
250 |
+
</a>
|
251 |
+
<span style='font-size: 1.3em'>{random_emojis[2]}</span>
|
252 |
+
</h3>
|
253 |
+
<div style='margin: 15px 0; color: #444; background: rgba(255,255,255,0.5);
|
254 |
+
padding: 15px; border-radius: 12px;'>
|
255 |
+
<p style='margin: 8px 0;'>
|
256 |
+
<strong>Status:</strong> โ
{state}
|
257 |
+
</p>
|
258 |
+
<p style='margin: 8px 0;'>
|
259 |
+
<strong>Created:</strong> ๐
{created}
|
260 |
+
</p>
|
261 |
+
</div>
|
262 |
+
<div style='margin-top: 20px;'>
|
263 |
+
<a href='https://{url}' target='_blank'
|
264 |
+
style='background: linear-gradient(45deg, #0084ff, #00a3ff);
|
265 |
+
color: white;
|
266 |
+
padding: 10px 20px;
|
267 |
+
border-radius: 15px;
|
268 |
+
text-decoration: none;
|
269 |
+
display: inline-flex;
|
270 |
+
align-items: center;
|
271 |
+
gap: 8px;
|
272 |
+
font-weight: 500;
|
273 |
+
transition: all 0.3s;
|
274 |
+
box-shadow: 0 2px 8px rgba(0,132,255,0.3);'
|
275 |
+
onmouseover='this.style.transform="scale(1.05)"; this.style.boxShadow="0 4px 12px rgba(0,132,255,0.4)"'
|
276 |
+
onmouseout='this.style.transform="scale(1)"; this.style.boxShadow="0 2px 8px rgba(0,132,255,0.3)"'>
|
277 |
+
<span>View Deployment</span> ๐
|
278 |
+
</a>
|
279 |
+
</div>
|
280 |
+
</div>
|
281 |
+
"""
|
282 |
+
|
283 |
+
# get_user_spaces ํจ์ ์์
|
284 |
def get_user_spaces():
|
285 |
+
# ๊ธฐ์กด Hugging Face ์คํ์ด์ค ๊ฐ์ ธ์ค๊ธฐ
|
286 |
url = f"https://huggingface.co/api/spaces?author={USERNAME}&limit=500"
|
287 |
headers = {
|
288 |
"Accept": "application/json",
|
|
|
290 |
}
|
291 |
|
292 |
try:
|
293 |
+
# Hugging Face ์คํ์ด์ค ๊ฐ์ ธ์ค๊ธฐ
|
294 |
response = requests.get(url, headers=headers)
|
295 |
+
spaces_data = response.json() if response.status_code == 200 else []
|
|
|
|
|
|
|
|
|
|
|
|
|
296 |
|
297 |
# ์ ์ธํ ์คํ์ด์ค ํํฐ๋ง
|
298 |
user_spaces = [
|
|
|
300 |
if not should_exclude_space(space.get('id', '').split('/')[-1])
|
301 |
]
|
302 |
|
303 |
+
# Vercel ๋ฐฐํฌ ๊ฐ์ ธ์ค๊ธฐ
|
304 |
+
vercel_deployments = get_vercel_deployments()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
|
306 |
html_content = f"""
|
307 |
<div style='padding: 20px; background-color: #f5f5f5;'>
|
|
|
310 |
<p style='color: #666; margin: 0 0 15px 0; font-size: 0.9em;'>
|
311 |
ํ๋กฌํํธ๋ง์ผ๋ก ๋๋ง์ ์น์๋น์ค๋ฅผ ์ฆ์ ์์ฑํ๋ MOUSE
|
312 |
<a href='https://openfree-mouse.hf.space' target='_blank'
|
313 |
+
style='color: #0084ff; text-decoration: none;'>
|
|
|
|
|
314 |
https://openfree-mouse.hf.space
|
315 |
</a>
|
316 |
</p>
|
317 |
+
<p style='color: #666; margin: 0;'>
|
318 |
+
Found {len(user_spaces)} Hugging Face spaces and {len(vercel_deployments)} Vercel deployments
|
319 |
+
</p>
|
320 |
</div>
|
321 |
+
|
322 |
+
<!-- Hugging Face Spaces -->
|
323 |
+
<h3 style='color: #333; margin: 20px 0;'>๐ค Hugging Face Spaces</h3>
|
324 |
+
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
|
|
325 |
{"".join(get_space_card(space, idx) for idx, space in enumerate(user_spaces))}
|
326 |
</div>
|
327 |
+
|
328 |
+
<!-- Vercel Deployments -->
|
329 |
+
<h3 style='color: #333; margin: 20px 0;'>โก Vercel Deployments</h3>
|
330 |
+
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
331 |
+
{"".join(get_vercel_card(dep, idx) for idx, dep in enumerate(vercel_deployments))}
|
332 |
+
</div>
|
333 |
</div>
|
334 |
"""
|
335 |
|
|
|
336 |
return html_content
|
337 |
|
338 |
except Exception as e:
|