openfree commited on
Commit
8c9d551
β€’
1 Parent(s): 3e40f7e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -15
app.py CHANGED
@@ -1,6 +1,7 @@
1
  import requests
2
  import gradio as gr
3
  from datetime import datetime
 
4
 
5
  USERNAME = "openfree"
6
 
@@ -10,7 +11,33 @@ def format_timestamp(timestamp):
10
  return dt.strftime('%Y-%m-%d %H:%M')
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]
@@ -46,24 +73,13 @@ def get_space_card(space):
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
  # μΆ”κ°€ μž₯μ‹μš© 이λͺ¨μ§€
@@ -190,7 +206,7 @@ def get_user_spaces():
190
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
191
  gap: 20px;
192
  '>
193
- {"".join(get_space_card(space) for space in user_spaces)}
194
  </div>
195
  </div>
196
  """
 
1
  import requests
2
  import gradio as gr
3
  from datetime import datetime
4
+ import random
5
 
6
  USERNAME = "openfree"
7
 
 
11
  return dt.strftime('%Y-%m-%d %H:%M')
12
  return 'N/A'
13
 
14
+ def get_pastel_color(index):
15
+ """Generate unique pastel colors based on index"""
16
+ pastel_colors = [
17
+ '#FFE6E6', # μ—°ν•œ 뢄홍
18
+ '#FFE6FF', # μ—°ν•œ 보라
19
+ '#E6E6FF', # μ—°ν•œ νŒŒλž‘
20
+ '#E6FFFF', # μ—°ν•œ ν•˜λŠ˜
21
+ '#E6FFE6', # μ—°ν•œ 초둝
22
+ '#FFFFE6', # μ—°ν•œ λ…Έλž‘
23
+ '#FFF0E6', # μ—°ν•œ μ£Όν™©
24
+ '#F0E6FF', # μ—°ν•œ 라벀더
25
+ '#FFE6F0', # μ—°ν•œ 둜즈
26
+ '#E6FFF0', # μ—°ν•œ 민트
27
+ '#F0FFE6', # μ—°ν•œ λΌμž„
28
+ '#FFE6EB', # μ—°ν•œ μ½”λž„
29
+ '#E6EBFF', # μ—°ν•œ νΌν”ŒλΈ”λ£¨
30
+ '#FFE6F5', # μ—°ν•œ 핑크
31
+ '#E6FFF5', # μ—°ν•œ ν„°μ½”μ΄μ¦ˆ
32
+ '#F5E6FF', # μ—°ν•œ λͺ¨λΈŒ
33
+ '#FFE6EC', # μ—°ν•œ μ‚΄λͺ¬
34
+ '#E6FFEC', # μ—°ν•œ μŠ€ν”„λ§κ·Έλ¦°
35
+ '#ECE6FF', # μ—°ν•œ νŽ˜λ¦¬μœ™ν΄
36
+ '#FFE6F7', # μ—°ν•œ 맀그놀리아
37
+ ]
38
+ return pastel_colors[index % len(pastel_colors)]
39
+
40
+ def get_space_card(space, index):
41
  """Generate HTML card for a space with colorful design and lots of emojis"""
42
  space_id = space.get('id', '')
43
  space_name = space_id.split('/')[-1]
 
73
  }
74
  }
75
 
76
+ # SDK에 λ”°λ₯Έ 이λͺ¨μ§€ 선택
 
 
 
 
 
 
 
 
 
 
77
  sdk_lower = sdk.lower()
78
+ bg_color = get_pastel_color(index) # 인덱슀 기반 색상 선택
79
  emoji_set = sdk_emoji_sets.get(sdk_lower, sdk_emoji_sets['N/A'])
80
  main_emoji = emoji_set['main']
81
 
82
  # λžœλ€ν•˜κ²Œ 3개의 κ΄€λ ¨ 이λͺ¨μ§€ 선택
 
83
  decorative_emojis = random.sample(emoji_set['related'], 3)
84
 
85
  # μΆ”κ°€ μž₯μ‹μš© 이λͺ¨μ§€
 
206
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
207
  gap: 20px;
208
  '>
209
+ {"".join(get_space_card(space, idx) for idx, space in enumerate(user_spaces))}
210
  </div>
211
  </div>
212
  """