fantos commited on
Commit
4b15de6
·
verified ·
1 Parent(s): e478a33

Delete app-backup2.py

Browse files
Files changed (1) hide show
  1. app-backup2.py +0 -135
app-backup2.py DELETED
@@ -1,135 +0,0 @@
1
- import urllib.parse
2
- import gradio as gr
3
-
4
- # ---------------------------
5
- # 배지 URL 생성 함수 정의
6
- # ---------------------------
7
- def generate_static_badge(label, message, color, label_color, logo, logo_color, style, link):
8
- base = "https://img.shields.io/static/v1"
9
- params = []
10
- if label:
11
- params.append(f"label={urllib.parse.quote(label, safe='')}")
12
- if message:
13
- params.append(f"message={urllib.parse.quote(message, safe='')}")
14
- if color:
15
- params.append(f"color={urllib.parse.quote(color, safe='')}")
16
- if label_color:
17
- params.append(f"labelColor={urllib.parse.quote(label_color, safe='')}")
18
- if logo:
19
- params.append(f"logo={urllib.parse.quote(logo, safe='')}")
20
- if logo_color:
21
- params.append(f"logoColor={urllib.parse.quote(logo_color, safe='')}")
22
- if style:
23
- params.append(f"style={urllib.parse.quote(style, safe='')}")
24
-
25
- badge_url = base + ("?" + "&".join(params) if params else "")
26
- if link:
27
- html_code = f'<a href="{link}" target="_blank"><img src="{badge_url}" alt="badge"></a>'
28
- else:
29
- html_code = f'<img src="{badge_url}" alt="badge">'
30
-
31
- badge_preview = f"""
32
- <div style='padding:20px; background: #fefefe; border-radius: 12px; display: flex; justify-content: center;'>
33
- {html_code}
34
- </div>
35
- """
36
- return html_code, badge_preview
37
-
38
- # ---------------------------
39
- # Gradio UI 구성
40
- # ---------------------------
41
- with gr.Blocks(theme=gr.themes.Default()) as demo:
42
- # 기존 static 예제 아이콘들
43
- gr.HTML("""
44
- <h1 style="text-align: center; font-size: 2.2em; margin-bottom: 0.2em;">🎨 BadgeCraft - Beautiful Badge Generator</h1>
45
- <p style="text-align: center; font-size: 1.1em; color: #555;">Design stylish shields.io badges with live preview and HTML snippet generation.</p>
46
- <h3 style="text-align: center; margin-top: 30px;">✨ Examples</h3>
47
- <div align="center" style="display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin: 10px 0 30px; justify-items: center;">
48
- <a href="https://discord.gg/openfreeai">
49
- <img alt="Discord" src="https://img.shields.io/badge/Discord-5865F2?style=for-the-badge&logo=discord&logoColor=white" />
50
- </a>
51
- <a href="https://x.com/openfree_ai">
52
- <img alt="X" src="https://img.shields.io/badge/X.com-000000?style=for-the-badge&logo=X&logoColor=white" />
53
- </a>
54
- <a href="https://huggingface.co/collections/VIDraft/best-open-ai-services-68057e6e312880ea92abaf4c">
55
- <img alt="Collections" src="https://img.shields.io/badge/Collections-F8F8F8?style=for-the-badge&logo=huggingface&logoColor=black" />
56
- </a>
57
- <a href="https://huggingface.co/VIDraft">
58
- <img alt="VIDraft" src="https://img.shields.io/badge/VIDraft-FCD022?style=for-the-badge&logo=huggingface&logoColor=black" />
59
- </a>
60
- <a href="https://github.com/openfreeai">
61
- <img src="https://img.shields.io/badge/GitHub-181717?style=for-the-badge&logo=github&logoColor=white" alt="GitHub">
62
- </a>
63
- <a href="https://twitter.com/openfree_ai">
64
- <img src="https://img.shields.io/badge/Twitter-1DA1F2?style=for-the-badge&logo=twitter&logoColor=white" alt="Twitter">
65
- </a>
66
- <a href="https://www.linkedin.com/company/openfreeai">
67
- <img src="https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white" alt="LinkedIn">
68
- </a>
69
- <a href="https://www.youtube.com/@AITechTree">
70
- <img src="https://img.shields.io/badge/YouTube-FF0000?style=for-the-badge&logo=youtube&logoColor=white" alt="YouTube">
71
- </a>
72
- <a href="https://huggingface.co/openfreeai">
73
- <img src="https://img.shields.io/badge/HuggingFace-FCC72E?style=for-the-badge&logo=huggingface&logoColor=black" alt="HuggingFace">
74
- </a>
75
- <a href="https://www.instagram.com/openfree_ai">
76
- <img src="https://img.shields.io/badge/Instagram-E4405F?style=for-the-badge&logo=instagram&logoColor=white" alt="Instagram">
77
- </a>
78
- <a href="https://www.threads.net/@openfree_ai">
79
- <img src="https://img.shields.io/badge/Threads-000000?style=for-the-badge&logo=threads&logoColor=white" alt="Threads">
80
- </a>
81
- <a href="https://www.facebook.com/profile.php?id=61575353674679">
82
- <img src="https://img.shields.io/badge/Facebook-1877F2?style=for-the-badge&logo=facebook&logoColor=white" alt="Facebook">
83
- </a>
84
- </div>
85
- """)
86
-
87
- # 출력 컴포넌트
88
- with gr.Row():
89
- out_code = gr.Code(label="HTML Snippet", language="html")
90
- out_preview = gr.HTML(label="Badge Preview")
91
-
92
- # 입력 컴포넌트
93
- with gr.Row():
94
- label = gr.Textbox(label="Label", placeholder="예: build")
95
- message = gr.Textbox(label="Message", placeholder="예: passing")
96
- logo = gr.Textbox(label="Logo", placeholder="예: github")
97
- with gr.Row():
98
- color = gr.ColorPicker(label="Color", value="#a0c4ff")
99
- label_color = gr.ColorPicker(label="Label Color", value="#bdb2ff")
100
- logo_color = gr.ColorPicker(label="Logo Color", value="#ffc6ff")
101
- style = gr.Dropdown(label="Style", choices=["flat", "flat-square", "plastic", "for-the-badge", "social"], value="for-the-badge")
102
- link = gr.Textbox(label="Link (배지 클릭 시 이동할 URL)", placeholder="https://yourlink.com")
103
-
104
- # Examples 데이터 (8개 필드 순서대로)
105
- examples = [
106
- ["Discord", "5865F2", "", "", "discord", "white", "for-the-badge", "https://discord.gg/openfreeai"],
107
- ["X.com", "000000", "", "", "X", "white", "for-the-badge", "https://x.com/openfree_ai"],
108
- ["Collections","F8F8F8", "", "", "huggingface","black", "for-the-badge", "https://huggingface.co/collections/VIDraft/best-open-ai-services-68057e6e312880ea92abaf4c"],
109
- ["VIDraft", "FCD022", "", "", "huggingface","black", "for-the-badge", "https://huggingface.co/VIDraft"],
110
- ["GitHub", "181717", "", "", "github", "white", "for-the-badge", "https://github.com/openfreeai"],
111
- ["Twitter", "1DA1F2", "", "", "twitter", "white", "for-the-badge", "https://twitter.com/openfree_ai"],
112
- ["YouTube", "FF0000", "", "", "youtube", "white", "for-the-badge", "https://www.youtube.com/@AITechTree"],
113
- ["Instagram", "E4405F", "", "", "instagram", "white", "for-the-badge", "https://www.instagram.com/openfree_ai"],
114
- ["Threads", "000000", "", "", "threads", "white", "for-the-badge", "https://www.threads.net/@openfree_ai"],
115
- ["Facebook", "1877F2", "", "", "facebook", "white", "for-the-badge", "https://www.facebook.com/profile.php?id=61575353674679"],
116
- ]
117
-
118
- gr.HTML("<h3 style='text-align: center; margin-top: 30px;'>✨ Click an example to autofill</h3>")
119
- gr.Examples(
120
- examples=examples,
121
- inputs=[label, message, color, label_color, logo, logo_color, style, link],
122
- outputs=[out_code, out_preview],
123
- fn=generate_static_badge,
124
- cache_examples=False,
125
- run_on_click=True
126
- )
127
-
128
- # 실시간 change 이벤트 바인딩
129
- inputs = [label, message, color, label_color, logo, logo_color, style, link]
130
- for inp in inputs:
131
- inp.change(fn=generate_static_badge, inputs=inputs, outputs=[out_code, out_preview])
132
-
133
- # 실행
134
- if __name__ == "__main__":
135
- demo.launch()