MBG0903 commited on
Commit
8c3cca9
ยท
verified ยท
1 Parent(s): f2ffd70

Update src/app.py

Browse files
Files changed (1) hide show
  1. src/app.py +132 -42
src/app.py CHANGED
@@ -1,65 +1,155 @@
1
  import streamlit as st
2
  import random
 
 
3
 
4
- # Page config
5
- st.set_page_config(
6
- page_title="AI Name Magic - Procelevate",
7
- page_icon="โœจ",
8
- layout="centered"
9
- )
10
 
11
- # --- Branding Header ---
12
- st.image("src/procelevate_logo.png", width=150)
13
  st.markdown(
14
- """
15
- <h1 style='color:#0F2C59; text-align:center;'>
16
- AI Name Magic โœจ
17
- </h1>
18
- <h4 style='text-align:center; color:#444;'>
19
- Powered by <span style="color:#0F2C59;">Procelevate Consulting</span>
20
- </h4>
21
  """,
22
- unsafe_allow_html=True
23
  )
24
 
25
- st.markdown("---")
26
-
27
- # --- Input Section ---
28
- st.subheader("๐Ÿ”ฎ Type Your Name & See AI Magic")
29
- name = st.text_input("Enter your name:")
30
 
31
- # Fun fact pool
32
  facts = [
33
  "AI predicts youโ€™ll be a Future Innovator ๐Ÿš€",
34
- "Your name glows with creativity ๐ŸŒŸ",
35
- "You might be the Next Data Scientist ๐Ÿ“Š",
36
  "AI says youโ€™ll shape the Future of Tech ๐Ÿค–",
37
- "Leadership is in your DNA ๐Ÿ’ก",
38
- "AI foresees a great journey ahead ๐ŸŒ"
39
  ]
40
 
41
- if name:
42
- styled_name = f"๐ŸŒŒ {name.upper()} ๐ŸŒŒ"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  st.markdown(
44
  f"""
45
- <h2 style='color:#0F2C59;
46
- text-shadow: 2px 2px #00FFFF, -2px -2px #FF00FF;
47
- font-size: 42px;
48
- text-align:center;'>
49
- {styled_name}
50
- </h2>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  """,
52
- unsafe_allow_html=True
53
  )
54
 
55
- st.success(random.choice(facts))
56
- st.info("๐Ÿ“ธ Take a picture of this screen to save your AI Magic moment!")
 
 
 
 
 
 
57
 
58
- # --- Footer ---
59
- st.markdown("---")
60
  st.markdown(
61
- "<p style='text-align:center; font-size:14px;'>"
62
- "ยฉ 2025 Procelevate Consulting | Elevating Processes. Empowering People."
63
- "</p>",
64
  unsafe_allow_html=True
65
  )
 
1
  import streamlit as st
2
  import random
3
+ from io import BytesIO
4
+ from PIL import Image, ImageDraw, ImageFont
5
 
6
+ # ---------- CONFIG ----------
7
+ BRAND = "#0F2C59" # Procelevate navy
8
+ ACCENT = "#00FFFF" # Cyan glow
9
+ PINK = "#FF00FF" # Magenta glow
10
+
11
+ st.set_page_config(page_title="AI Name Magic - Procelevate", page_icon="โœจ", layout="centered")
12
 
13
+ # ---------- HEADER ----------
 
14
  st.markdown(
15
+ f"""
16
+ <div style="text-align:center; margin-top:10px;">
17
+ <h1 style="margin:0; color:{BRAND};">AI Name Magic โœจ</h1>
18
+ <div style="font-size:20px; color:#1f2937;">Powered by <b style="color:{BRAND};">Procelevate Consulting</b></div>
19
+ </div>
20
+ <hr style="opacity:.2;"/>
 
21
  """,
22
+ unsafe_allow_html=True,
23
  )
24
 
25
+ # ---------- INPUT ----------
26
+ with st.form("name_form", clear_on_submit=False):
27
+ st.subheader("๐Ÿ”ฎ Type Your Name & See AI Magic")
28
+ name = st.text_input("Enter your name:")
29
+ submitted = st.form_submit_button("Show My AI Prediction ๐Ÿš€")
30
 
31
+ # ---------- FUN FACTS ----------
32
  facts = [
33
  "AI predicts youโ€™ll be a Future Innovator ๐Ÿš€",
34
+ "You have the next big idea that transform the world ๐Ÿ’ก",
35
+ "You might be the Next Data Scientist / Data Engineer ๐Ÿ“Š",
36
  "AI says youโ€™ll shape the Future of Tech ๐Ÿค–",
37
+ "Leadership and technology is in your DNA ๐ŸŒŸ",
38
+ "AI foresees the future CEO / CTO of a biggest company...! ๐ŸŒ",
39
  ]
40
 
41
+ def make_card(name_text: str, fact_text: str) -> bytes:
42
+ """Create a branded PNG 'Future Me Card'."""
43
+ W, H = 1200, 630
44
+ img = Image.new("RGB", (W, H), (15,44,89)) # #0F2C59 background
45
+ draw = ImageDraw.Draw(img)
46
+
47
+ # subtle gradient overlay
48
+ grad = Image.new("RGB", (W, H))
49
+ for y in range(H):
50
+ c = int(255 * (y / H) * 0.18) # very light cyan tint
51
+ grad.putpixel((0, y), (0, 180, 180 - c))
52
+ grad = grad.resize((W, H))
53
+ img = Image.blend(img, grad, 0.15)
54
+ draw = ImageDraw.Draw(img)
55
+
56
+ # Load logo if available
57
+ try:
58
+ logo = Image.open("src/procelevate_logo.png").convert("RGBA")
59
+ base = 140
60
+ logo = logo.resize((base, base))
61
+ img.paste(logo, (50, 50), logo)
62
+ except Exception:
63
+ pass
64
+
65
+ # Fallback fonts (Pillow will map to system fonts in slim image)
66
+ try:
67
+ title_font = ImageFont.truetype("DejaVuSans-Bold.ttf", 70)
68
+ name_font = ImageFont.truetype("DejaVuSans-Bold.ttf", 120)
69
+ fact_font = ImageFont.truetype("DejaVuSans.ttf", 46)
70
+ except:
71
+ title_font = ImageFont.load_default()
72
+ name_font = ImageFont.load_default()
73
+ fact_font = ImageFont.load_default()
74
+
75
+ # Title
76
+ title = "YOUR AI PREDICTION"
77
+ tw, th = draw.textlength(title, font=title_font), title_font.size
78
+ draw.rounded_rectangle([(400, 70), (400+tw+60, 70+th+40)], radius=18, fill=(255,255,255))
79
+ draw.text((430, 90), title, font=title_font, fill=(15,44,89))
80
+
81
+ # Name (neon effect)
82
+ name_text = name_text.upper()
83
+ nx, ny = 120, 260
84
+ # Magenta / cyan shadow
85
+ draw.text((nx+6, ny+6), name_text, font=name_font, fill=(255,0,255))
86
+ draw.text((nx-6, ny-6), name_text, font=name_font, fill=(0,255,255))
87
+ draw.text((nx, ny), name_text, font=name_font, fill=(255,255,255))
88
+
89
+ # Fact
90
+ fact_box_y = ny + 170
91
+ draw.rounded_rectangle([(80, fact_box_y), (W-80, fact_box_y+170)], radius=24, fill=(255,255,255))
92
+ draw.text((110, fact_box_y+55), f"โœจ {fact_text}", font=fact_font, fill=(15,44,89))
93
+
94
+ # Footer
95
+ footer = "ยฉ Procelevate Academy โ€ข Learn -> Transform -> Elevate."
96
+ fw, _ = draw.textlength(footer, font=ImageFont.truetype("DejaVuSans.ttf", 28)), 28
97
+ draw.text(((W-fw)//2, H-60), footer, font=ImageFont.truetype("DejaVuSans.ttf", 28), fill=(230,240,245))
98
+
99
+ buf = BytesIO()
100
+ img.save(buf, format="PNG")
101
+ buf.seek(0)
102
+ return buf.getvalue()
103
+
104
+ # ---------- OUTPUT ----------
105
+ if submitted and name.strip():
106
+ fact = random.choice(facts)
107
+
108
+ # Confetti ๐ŸŽˆ
109
+ st.balloons()
110
+
111
+ # Neon Name Banner
112
  st.markdown(
113
  f"""
114
+ <div style="
115
+ margin: 10px auto 0 auto;
116
+ max-width: 820px;
117
+ text-align:center;
118
+ padding: 18px 22px;
119
+ border-radius: 16px;
120
+ background:
121
+ radial-gradient(circle at 20% 10%, rgba(0,255,255,.25), transparent 40%),
122
+ radial-gradient(circle at 80% 0%, rgba(255,0,255,.25), transparent 35%),
123
+ linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
124
+ border: 2px solid #e6eef7;">
125
+ <div style="font-size:14px; letter-spacing:1px; color:{BRAND}; font-weight:700;
126
+ display:inline-block; padding:6px 12px; border-radius:999px; background:#e6f3ff; margin-bottom:8px;">
127
+ YOUR AI PREDICTION
128
+ </div>
129
+ <h1 style="margin:4px 0 8px 0; font-size:56px; color:{BRAND};
130
+ text-shadow: 2px 2px {ACCENT}, -2px -2px {PINK};">
131
+ {name.upper()}
132
+ </h1>
133
+ <div style="font-size:22px; color:#0b2239; padding:12px 16px; border-radius:12px;
134
+ background:#f0f9ff; display:inline-block;">
135
+ โœจ {fact}
136
+ </div>
137
+ </div>
138
  """,
139
+ unsafe_allow_html=True,
140
  )
141
 
142
+ # Build and show downloadable card
143
+ png_bytes = make_card(name, fact)
144
+ st.download_button("โฌ‡๏ธ Download My Future Me Card (PNG)", data=png_bytes,
145
+ file_name=f"{name.replace(' ','_')}_future_me.png", mime="image/png")
146
+
147
+ st.caption("Tip: Save the card or share it with your friends!")
148
+ elif submitted:
149
+ st.warning("Please enter your name first ๐Ÿ™‚")
150
 
151
+ st.markdown("<hr style='opacity:.2;'/>", unsafe_allow_html=True)
 
152
  st.markdown(
153
+ "<p style='text-align:center; font-size:14px;'>ยฉ 2025 Procelevate Consulting</p>",
 
 
154
  unsafe_allow_html=True
155
  )