Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,41 +11,140 @@ def format_timestamp(timestamp):
|
|
11 |
return 'N/A'
|
12 |
|
13 |
def get_space_card(space):
|
14 |
-
"""Generate HTML card for a space"""
|
15 |
space_id = space.get('id', '')
|
16 |
space_name = space_id.split('/')[-1]
|
17 |
likes = space.get('likes', 0)
|
18 |
created_at = format_timestamp(space.get('createdAt'))
|
19 |
sdk = space.get('sdk', 'N/A')
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
return f"""
|
22 |
-
<div style='border:
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
<a href='https://huggingface.co/spaces/{space_id}' target='_blank'
|
29 |
style='text-decoration: none; color: #2d2d2d;'>
|
30 |
{space_name}
|
31 |
</a>
|
|
|
32 |
</h3>
|
33 |
-
<div style='margin:
|
34 |
-
|
35 |
-
<p style='margin:
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
</div>
|
38 |
-
<div style='margin-top:
|
|
|
|
|
|
|
39 |
<a href='https://huggingface.co/spaces/{space_id}' target='_blank'
|
40 |
-
style='background
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
</a>
|
47 |
-
<span style='color: #666; font-size: 0.9em;'>
|
48 |
-
|
49 |
</span>
|
50 |
</div>
|
51 |
</div>
|
|
|
11 |
return 'N/A'
|
12 |
|
13 |
def get_space_card(space):
|
14 |
+
"""Generate HTML card for a space with colorful design and lots of emojis"""
|
15 |
space_id = space.get('id', '')
|
16 |
space_name = space_id.split('/')[-1]
|
17 |
likes = space.get('likes', 0)
|
18 |
created_at = format_timestamp(space.get('createdAt'))
|
19 |
sdk = space.get('sdk', 'N/A')
|
20 |
|
21 |
+
# SDKλ³ μ΄λͺ¨μ§ λ° κ΄λ ¨ μ΄λͺ¨μ§ μΈνΈ
|
22 |
+
sdk_emoji_sets = {
|
23 |
+
'gradio': {
|
24 |
+
'main': 'π¨',
|
25 |
+
'related': ['πΌοΈ', 'π', 'πͺ', 'π ', 'π‘', 'π’', 'π―', 'π²', 'π°', 'π³']
|
26 |
+
},
|
27 |
+
'streamlit': {
|
28 |
+
'main': 'β‘',
|
29 |
+
'related': ['π«', 'β¨', 'β', 'π', 'π₯', 'β‘', 'π₯', 'π', 'π', 'π']
|
30 |
+
},
|
31 |
+
'docker': {
|
32 |
+
'main': 'π³',
|
33 |
+
'related': ['π', 'π', 'π', 'π’', 'β΄οΈ', 'π₯οΈ', 'π ', 'π‘', 'π¦', 'π¬']
|
34 |
+
},
|
35 |
+
'static': {
|
36 |
+
'main': 'π',
|
37 |
+
'related': ['π', 'π°', 'π', 'ποΈ', 'π', 'π', 'π', 'π', 'π', 'π']
|
38 |
+
},
|
39 |
+
'panel': {
|
40 |
+
'main': 'π',
|
41 |
+
'related': ['π', 'π', 'πΉ', 'π', 'π', 'π', 'πΊοΈ', 'π―', 'π', 'π']
|
42 |
+
},
|
43 |
+
'N/A': {
|
44 |
+
'main': 'π§',
|
45 |
+
'related': ['π¨', 'βοΈ', 'π οΈ', 'βοΈ', 'π©', 'βοΈ', 'β‘', 'π', 'π‘', 'π']
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
# νμ€ν
ν€ λ°°κ²½μ
|
50 |
+
bg_colors = {
|
51 |
+
'gradio': '#FFE6E6', # μ°ν λΆν
|
52 |
+
'streamlit': '#E6FFE6', # μ°ν μ΄λ‘
|
53 |
+
'docker': '#E6E6FF', # μ°ν νλ
|
54 |
+
'static': '#FFE6FF', # μ°ν 보λΌ
|
55 |
+
'panel': '#FFFFE6', # μ°ν λ
Έλ
|
56 |
+
'N/A': '#E6FFFF' # μ°ν νλ
|
57 |
+
}
|
58 |
+
|
59 |
+
# SDKμ λ°λ₯Έ μ΄λͺ¨μ§μ μμ μ ν
|
60 |
+
sdk_lower = sdk.lower()
|
61 |
+
bg_color = bg_colors.get(sdk_lower, '#FFFFFF')
|
62 |
+
emoji_set = sdk_emoji_sets.get(sdk_lower, sdk_emoji_sets['N/A'])
|
63 |
+
main_emoji = emoji_set['main']
|
64 |
+
|
65 |
+
# λλ€νκ² 3κ°μ κ΄λ ¨ μ΄λͺ¨μ§ μ ν
|
66 |
+
import random
|
67 |
+
decorative_emojis = random.sample(emoji_set['related'], 3)
|
68 |
+
|
69 |
+
# μΆκ° μ₯μμ© μ΄λͺ¨μ§
|
70 |
+
general_emojis = ['π', 'π«', 'β', 'π', 'β¨', 'π₯', 'π₯', 'π', 'π―', 'π¨',
|
71 |
+
'π', 'πͺ', 'π’', 'π‘', 'π ', 'πͺ', 'π', 'π¨', 'π―', 'π²']
|
72 |
+
random_emojis = random.sample(general_emojis, 3)
|
73 |
+
|
74 |
+
# μ’μμ μμ λ°λ₯Έ ννΈ μ΄λͺ¨μ§
|
75 |
+
heart_emoji = 'β€οΈ' if likes > 100 else 'π' if likes > 50 else 'π' if likes > 10 else 'π€'
|
76 |
+
|
77 |
return f"""
|
78 |
+
<div style='border: none;
|
79 |
+
padding: 25px;
|
80 |
+
margin: 15px;
|
81 |
+
border-radius: 20px;
|
82 |
+
background-color: {bg_color};
|
83 |
+
box-shadow: 0 4px 15px rgba(0,0,0,0.1);
|
84 |
+
transition: all 0.3s ease-in-out;
|
85 |
+
position: relative;
|
86 |
+
overflow: hidden;'
|
87 |
+
onmouseover='this.style.transform="translateY(-5px) scale(1.02)"; this.style.boxShadow="0 8px 25px rgba(0,0,0,0.15)"'
|
88 |
+
onmouseout='this.style.transform="translateY(0) scale(1)"; this.style.boxShadow="0 4px 15px rgba(0,0,0,0.1)"'>
|
89 |
+
<div style='position: absolute; top: -15px; right: -15px; font-size: 100px; opacity: 0.1;'>
|
90 |
+
{main_emoji}
|
91 |
+
</div>
|
92 |
+
<div style='position: absolute; top: 10px; right: 10px; font-size: 20px;'>
|
93 |
+
{decorative_emojis[0]}
|
94 |
+
</div>
|
95 |
+
<div style='position: absolute; bottom: 10px; left: 10px; font-size: 20px;'>
|
96 |
+
{decorative_emojis[1]}
|
97 |
+
</div>
|
98 |
+
<div style='position: absolute; top: 50%; right: 10px; font-size: 20px;'>
|
99 |
+
{decorative_emojis[2]}
|
100 |
+
</div>
|
101 |
+
<h3 style='color: #2d2d2d;
|
102 |
+
margin: 0 0 20px 0;
|
103 |
+
font-size: 1.4em;
|
104 |
+
display: flex;
|
105 |
+
align-items: center;
|
106 |
+
gap: 10px;'>
|
107 |
+
<span style='font-size: 1.3em'>{random_emojis[0]}</span>
|
108 |
<a href='https://huggingface.co/spaces/{space_id}' target='_blank'
|
109 |
style='text-decoration: none; color: #2d2d2d;'>
|
110 |
{space_name}
|
111 |
</a>
|
112 |
+
<span style='font-size: 1.3em'>{random_emojis[1]}</span>
|
113 |
</h3>
|
114 |
+
<div style='margin: 15px 0; color: #444; background: rgba(255,255,255,0.5);
|
115 |
+
padding: 15px; border-radius: 12px;'>
|
116 |
+
<p style='margin: 8px 0;'>
|
117 |
+
<strong>SDK:</strong> {main_emoji} {sdk} {decorative_emojis[0]}
|
118 |
+
</p>
|
119 |
+
<p style='margin: 8px 0;'>
|
120 |
+
<strong>Created:</strong> π
{created_at} β°
|
121 |
+
</p>
|
122 |
+
<p style='margin: 8px 0;'>
|
123 |
+
<strong>Likes:</strong> {heart_emoji} {likes} {random_emojis[2]}
|
124 |
+
</p>
|
125 |
</div>
|
126 |
+
<div style='margin-top: 20px;
|
127 |
+
display: flex;
|
128 |
+
justify-content: space-between;
|
129 |
+
align-items: center;'>
|
130 |
<a href='https://huggingface.co/spaces/{space_id}' target='_blank'
|
131 |
+
style='background: linear-gradient(45deg, #0084ff, #00a3ff);
|
132 |
+
color: white;
|
133 |
+
padding: 10px 20px;
|
134 |
+
border-radius: 15px;
|
135 |
+
text-decoration: none;
|
136 |
+
display: inline-flex;
|
137 |
+
align-items: center;
|
138 |
+
gap: 8px;
|
139 |
+
font-weight: 500;
|
140 |
+
transition: all 0.3s;
|
141 |
+
box-shadow: 0 2px 8px rgba(0,132,255,0.3);'
|
142 |
+
onmouseover='this.style.transform="scale(1.05)"; this.style.boxShadow="0 4px 12px rgba(0,132,255,0.4)"'
|
143 |
+
onmouseout='this.style.transform="scale(1)"; this.style.boxShadow="0 2px 8px rgba(0,132,255,0.3)"'>
|
144 |
+
<span>View Space</span> π {random_emojis[0]}
|
145 |
</a>
|
146 |
+
<span style='color: #666; font-size: 0.9em; opacity: 0.7;'>
|
147 |
+
π {space_id} {decorative_emojis[2]}
|
148 |
</span>
|
149 |
</div>
|
150 |
</div>
|