Darbar-e-Dil / app.py
TouseefAhmad's picture
Create app.py
dca071b verified
Raw
History Blame Contribute Delete
11.9 kB
import streamlit as st
import random
import time
from datetime import datetime
# Page configuration
st.set_page_config(
page_title="Darbar-e-Dil | دربارِ دل",
page_icon="💖",
layout="centered",
initial_sidebar_state="collapsed"
)
# Custom CSS for enhanced styling
st.markdown("""
<style>
@import url('https://fonts.googleapis.com/css2?family=Noto+Nastaliq+Urdu:wght@400;700&family=Dancing+Script:wght@400;700&display=swap');
.main-header {
text-align: center;
padding: 2rem 0;
background: linear-gradient(135deg, #ff6b6b, #ffd93d);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
font-family: 'Dancing Script', cursive;
font-size: 3.5rem;
font-weight: 700;
margin-bottom: 1rem;
}
.urdu-header {
text-align: center;
font-family: 'Noto Nastaliq Urdu', serif;
font-size: 2.5rem;
color: #e91e63;
margin-bottom: 2rem;
text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}
.subtitle {
text-align: center;
font-size: 1.2rem;
color: #666;
margin-bottom: 2rem;
font-style: italic;
}
.compliment-card {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
padding: 2rem;
border-radius: 15px;
margin: 2rem 0;
box-shadow: 0 10px 30px rgba(0,0,0,0.2);
color: white;
text-align: center;
animation: fadeIn 0.8s ease-in;
}
.compliment-text {
font-size: 1.3rem;
line-height: 1.6;
margin-bottom: 1rem;
font-weight: 500;
}
.urdu-compliment {
font-family: 'Noto Nastaliq Urdu', serif;
font-size: 1.5rem;
line-height: 1.8;
margin-top: 1rem;
color: #ffd93d;
direction: rtl;
text-align: right;
}
.heart-divider {
text-align: center;
font-size: 2rem;
color: #ff6b6b;
margin: 1rem 0;
}
.stButton > button {
background: linear-gradient(45deg, #ff6b6b, #ffd93d);
color: white;
border: none;
padding: 0.75rem 2rem;
border-radius: 25px;
font-size: 1.1rem;
font-weight: 600;
transition: all 0.3s ease;
width: 100%;
}
.stButton > button:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}
.sidebar-content {
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
padding: 1rem;
border-radius: 10px;
margin: 1rem 0;
}
.footer {
text-align: center;
margin-top: 3rem;
padding: 2rem;
color: #666;
font-style: italic;
}
</style>
""", unsafe_allow_html=True)
# Compliment templates with placeholders
COMPLIMENT_TEMPLATES = {
'beauty_based': [
"Your name {name} means {meaning}, and just like its meaning, your beauty illuminates every corner of my heart. You are the definition of grace and elegance.",
"Like the meaning of {name} - {meaning}, your presence brings light to my darkest days. Your smile is more radiant than a thousand stars.",
"The name {name} carries the essence of {meaning}, and you embody this beauty in every breath you take. You are poetry in motion.",
],
'personality_based': [
"Your name {name}, meaning {meaning}, perfectly captures your incredible spirit. Your kindness touches every soul you meet.",
"Just as {name} means {meaning}, your heart reflects the same beautiful qualities. You make the world a better place simply by existing.",
"The meaning of {name} - {meaning} - is written in your every gesture. Your compassion knows no bounds.",
],
'romantic': [
"My beloved {name}, your name means {meaning}, and you mean everything to me. My heart beats only for you.",
"In the garden of my heart, you bloom like the most beautiful flower. {name}, meaning {meaning}, you are my eternal love.",
"Every letter of your name {name} spells magic, and its meaning {meaning} describes the miracle you are in my life.",
]
}
# Urdu compliments corresponding to each category
URDU_COMPLIMENTS = {
'beauty_based': [
"آپ کا نام {name} ہے جس کا مطلب {meaning} ہے، اور آپ اپنے نام کی طرح ہی خوبصورت ہیں۔ آپ کی خوبصورتی چاند کو بھی شرمندہ کر دیتی ہے۔",
"جیسے آپ کے نام {name} کا مطلب {meaning} ہے، ویسے ہی آپ کی خوبصورتی میرے دل کو روشن کر دیتی ہے۔",
"آپ کا نام {name} ہے اور اس کا مطلب {meaning} ہے، لیکن آپ کی خوبصورتی کا کوئی مطلب نہیں، وہ تو بے مثال ہے۔",
],
'personality_based': [
"آپ کا نام {name} ہے جس کا مطلب {meaning} ہے، اور آپ کی شخصیت بالکل اسی طرح پیاری ہے۔",
"جس طرح {name} کا مطلب {meaning} ہے، اسی طرح آپ کا دل بھی اتنا ہی پاک اور صاف ہے۔",
"آپ کے نام {name} کا مطلب {meaning} ہے، اور آپ اس کی زندہ مثال ہیں۔",
],
'romantic': [
"میری محبوبہ {name}، آپ کے نام کا مطلب {meaning} ہے، لیکن میرے لیے آپ کا مطلب زندگی ہے۔",
"آپ کا نام {name} ہے اور اس کا مطلب {meaning} ہے، لیکن میرے دل میں آپ کا مطلب عشق ہے۔",
"جب سے آپ کو دیکھا ہے {name}، میرا دل صرف آپ کا ہو گیا ہے۔ آپ کے نام کا مطلب {meaning} ہے، لیکن میرے لیے آپ کا مطلب محبت ہے۔",
]
}
def generate_compliment(name, meaning):
"""Generate a romantic compliment based on name and meaning"""
if not name or not meaning:
return None, None
# Choose random category
category = random.choice(list(COMPLIMENT_TEMPLATES.keys()))
# Get templates for the category
english_templates = COMPLIMENT_TEMPLATES[category]
urdu_templates = URDU_COMPLIMENTS[category]
# Choose random template from category
english_template = random.choice(english_templates)
urdu_template = random.choice(urdu_templates)
# Format with name and meaning
english_compliment = english_template.format(name=name, meaning=meaning)
urdu_compliment = urdu_template.format(name=name, meaning=meaning)
return english_compliment, urdu_compliment
def display_floating_hearts():
"""Display animated hearts effect"""
st.markdown("""
<div style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: -1;">
<div style="position: absolute; top: 10%; left: 10%; animation: float 6s ease-in-out infinite;">💖</div>
<div style="position: absolute; top: 20%; right: 15%; animation: float 8s ease-in-out infinite 2s;">💕</div>
<div style="position: absolute; bottom: 30%; left: 20%; animation: float 7s ease-in-out infinite 4s;">💗</div>
<div style="position: absolute; bottom: 15%; right: 10%; animation: float 9s ease-in-out infinite 1s;">💝</div>
</div>
<style>
@keyframes float {
0%, 100% { transform: translateY(0px) rotate(0deg); opacity: 0.7; }
50% { transform: translateY(-20px) rotate(180deg); opacity: 1; }
}
</style>
""", unsafe_allow_html=True)
# Main app
def main():
# Floating hearts background
display_floating_hearts()
# Header
st.markdown('<h1 class="main-header">Darbar-e-Dil</h1>', unsafe_allow_html=True)
st.markdown('<h2 class="urdu-header">دربارِ دل</h2>', unsafe_allow_html=True)
st.markdown('<p class="subtitle">Where hearts speak the language of love | جہاں دل محبت کی زبان بولتے ہیں</p>', unsafe_allow_html=True)
# Heart divider
st.markdown('<div class="heart-divider">💖 ✨ 💖</div>', unsafe_allow_html=True)
# Input section
col1, col2 = st.columns(2)
with col1:
name = st.text_input("💝 Enter the beautiful name | خوبصورت نام درج کریں",
placeholder="e.g., Ayesha, Fatima, Zara")
with col2:
meaning = st.text_input("🌟 Enter the meaning | مطلب درج کریں",
placeholder="e.g., Living, Pure, Blooming flower")
# Generate button
if st.button("💕 Generate Romantic Compliment | رومانٹک تعریف بنائیں"):
if name and meaning:
# Show loading animation
with st.spinner('Creating something beautiful for you... | آپ کے لیے کچھ خوبصورت بنایا جا رہا ہے...'):
time.sleep(2) # Add some suspense
# Generate compliments
english_compliment, urdu_compliment = generate_compliment(name.strip().title(), meaning.strip().lower())
if english_compliment and urdu_compliment:
# Display compliment card
st.markdown(f"""
<div class="compliment-card">
<div class="compliment-text">{english_compliment}</div>
<div class="heart-divider">💖</div>
<div class="urdu-compliment">{urdu_compliment}</div>
</div>
""", unsafe_allow_html=True)
# Success message
st.success("💕 Your romantic compliment is ready! | آپ کی رومانٹک تعریف تیار ہے!")
# Share button
st.markdown("---")
col1, col2, col3 = st.columns([1,2,1])
with col2:
if st.button("🎁 Generate Another One | ایک اور بنائیں"):
st.experimental_rerun()
else:
st.error("💔 Please enter both name and meaning | برائے کرم نام اور مطلب دونوں درج کریں")
# Sidebar with additional features
with st.sidebar:
st.markdown("### 💖 About Darbar-e-Dil")
st.markdown("**دربارِ دل کے بارے میں**")
st.markdown("""
This app creates personalized romantic compliments based on names and their meanings.
یہ ایپ ناموں اور ان کے معنی کی بنیاد پر ذاتی رومانٹک تعریفیں بناتی ہے۔
""")
st.markdown("---")
st.markdown("### 🌟 Features | خصوصیات")
st.markdown("""
- ✨ Personalized compliments
- 💕 English & Urdu support
- 🎨 Beautiful design
- 💖 Romantic expressions
""")
st.markdown("---")
# Statistics
if 'compliment_count' not in st.session_state:
st.session_state.compliment_count = 0
if name and meaning and st.session_state.get('last_generated'):
st.session_state.compliment_count += 1
st.markdown(f"### 📊 Compliments Generated Today")
st.markdown(f"**{st.session_state.compliment_count}** beautiful compliments created!")
# Footer
st.markdown("""
<div class="footer">
<p>Made with 💖 for expressing love in beautiful words</p>
<p>محبت کو خوبصورت الفاظ میں بیان کرنے کے لیے 💖 کے ساتھ بنایا گیا</p>
</div>
""", unsafe_allow_html=True)
if __name__ == "__main__":
main()