Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -13,7 +13,7 @@ def format_timestamp(timestamp):
|
|
13 |
|
14 |
def get_space_card(space):
|
15 |
"""Generate HTML card for a space"""
|
16 |
-
space_name = space["
|
17 |
return f"""
|
18 |
<div style='border: 1px solid #ddd; padding: 15px; margin: 10px; border-radius: 8px;
|
19 |
background-color: white; box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
|
@@ -21,19 +21,18 @@ def get_space_card(space):
|
|
21 |
onmouseover='this.style.transform="scale(1.02)"'
|
22 |
onmouseout='this.style.transform="scale(1)"'>
|
23 |
<h3 style='color: #2d2d2d; margin: 0 0 10px 0;'>
|
24 |
-
<a href='https://huggingface.co/spaces/{
|
25 |
style='text-decoration: none; color: #2d2d2d;'>
|
26 |
{space_name}
|
27 |
</a>
|
28 |
</h3>
|
29 |
-
<p style='margin: 5px 0;'><strong>
|
30 |
-
{space.get("
|
31 |
-
|
32 |
-
|
33 |
-
<p style='margin: 5px 0;'><strong>
|
34 |
-
{space.get("likes", 0)} ❤️</p>
|
35 |
<div style='margin-top: 10px;'>
|
36 |
-
<a href='https://huggingface.co/spaces/{
|
37 |
style='background-color: #0084ff; color: white; padding: 5px 10px;
|
38 |
border-radius: 5px; text-decoration: none; display: inline-block;'>
|
39 |
View Space
|
@@ -43,16 +42,25 @@ def get_space_card(space):
|
|
43 |
"""
|
44 |
|
45 |
def get_user_spaces():
|
46 |
-
#
|
47 |
response = requests.get(
|
48 |
-
f"https://huggingface.co/api/
|
49 |
headers={"Accept": "application/json"}
|
50 |
)
|
51 |
|
|
|
|
|
|
|
|
|
52 |
if response.status_code != 200:
|
53 |
return f"Error: Failed to fetch spaces (Status Code: {response.status_code})"
|
54 |
|
55 |
-
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
if not spaces:
|
58 |
return "No public Spaces found for this user."
|
|
|
13 |
|
14 |
def get_space_card(space):
|
15 |
"""Generate HTML card for a space"""
|
16 |
+
space_name = space["id"].split('/')[-1] if 'id' in space else space.get('name', 'Unknown')
|
17 |
return f"""
|
18 |
<div style='border: 1px solid #ddd; padding: 15px; margin: 10px; border-radius: 8px;
|
19 |
background-color: white; box-shadow: 2px 2px 5px rgba(0,0,0,0.1);
|
|
|
21 |
onmouseover='this.style.transform="scale(1.02)"'
|
22 |
onmouseout='this.style.transform="scale(1)"'>
|
23 |
<h3 style='color: #2d2d2d; margin: 0 0 10px 0;'>
|
24 |
+
<a href='https://huggingface.co/spaces/{USERNAME}/{space_name}' target='_blank'
|
25 |
style='text-decoration: none; color: #2d2d2d;'>
|
26 |
{space_name}
|
27 |
</a>
|
28 |
</h3>
|
29 |
+
<p style='margin: 5px 0;'><strong>Status:</strong>
|
30 |
+
<span style='color: {"green" if space.get("status") == "running" else "orange"}'>
|
31 |
+
{space.get("status", "unknown")}</span>
|
32 |
+
</p>
|
33 |
+
<p style='margin: 5px 0;'><strong>SDK:</strong> {space.get("sdk", "N/A")}</p>
|
|
|
34 |
<div style='margin-top: 10px;'>
|
35 |
+
<a href='https://huggingface.co/spaces/{USERNAME}/{space_name}' target='_blank'
|
36 |
style='background-color: #0084ff; color: white; padding: 5px 10px;
|
37 |
border-radius: 5px; text-decoration: none; display: inline-block;'>
|
38 |
View Space
|
|
|
42 |
"""
|
43 |
|
44 |
def get_user_spaces():
|
45 |
+
# 직접 spaces API 호출
|
46 |
response = requests.get(
|
47 |
+
f"https://huggingface.co/api/spaces/{USERNAME}",
|
48 |
headers={"Accept": "application/json"}
|
49 |
)
|
50 |
|
51 |
+
# 디버깅을 위한 출력
|
52 |
+
print(f"Status Code: {response.status_code}")
|
53 |
+
print(f"Response: {response.text}")
|
54 |
+
|
55 |
if response.status_code != 200:
|
56 |
return f"Error: Failed to fetch spaces (Status Code: {response.status_code})"
|
57 |
|
58 |
+
try:
|
59 |
+
spaces = response.json()
|
60 |
+
if not isinstance(spaces, list):
|
61 |
+
spaces = [spaces]
|
62 |
+
except Exception as e:
|
63 |
+
return f"Error parsing response: {str(e)}"
|
64 |
|
65 |
if not spaces:
|
66 |
return "No public Spaces found for this user."
|