openfree commited on
Commit
3e40f7e
β€’
1 Parent(s): 20c904c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +119 -20
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: 1px solid #ddd; padding: 20px; margin: 10px; border-radius: 12px;
23
- background-color: white; box-shadow: 2px 2px 10px rgba(0,0,0,0.1);
24
- transition: transform 0.2s ease-in-out;'
25
- onmouseover='this.style.transform="scale(1.02)"'
26
- onmouseout='this.style.transform="scale(1)"'>
27
- <h3 style='color: #2d2d2d; margin: 0 0 15px 0; font-size: 1.3em;'>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: 10px 0; color: #666;'>
34
- <p style='margin: 5px 0;'><strong>SDK:</strong> {sdk}</p>
35
- <p style='margin: 5px 0;'><strong>Created:</strong> {created_at}</p>
36
- <p style='margin: 5px 0;'><strong>Likes:</strong> {likes} ❀️</p>
 
 
 
 
 
 
 
37
  </div>
38
- <div style='margin-top: 15px; display: flex; justify-content: space-between; align-items: center;'>
 
 
 
39
  <a href='https://huggingface.co/spaces/{space_id}' target='_blank'
40
- style='background-color: #0084ff; color: white; padding: 8px 16px;
41
- border-radius: 6px; text-decoration: none; display: inline-block;
42
- font-weight: 500; transition: background-color 0.2s;'
43
- onmouseover='this.style.backgroundColor="#0066cc"'
44
- onmouseout='this.style.backgroundColor="#0084ff"'>
45
- View Space
 
 
 
 
 
 
 
 
46
  </a>
47
- <span style='color: #666; font-size: 0.9em;'>
48
- ID: {space_id}
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>