Spaces:
Running
Running
File size: 3,834 Bytes
ce81e14 bf2ed00 ce81e14 8d05c91 ce81e14 bf2ed00 ce81e14 a12efc5 ce81e14 a12efc5 ce81e14 a12efc5 ce81e14 a12efc5 ce81e14 a12efc5 ce81e14 a12efc5 ce81e14 bf2ed00 ce81e14 a12efc5 ce81e14 2fe65ab bf2ed00 ce81e14 bf2ed00 2fe65ab ce81e14 bf2ed00 8d05c91 2fe65ab bf2ed00 90fec3d 2fe65ab bf2ed00 90fec3d ce81e14 2fe65ab bf2ed00 ce81e14 2fe65ab 8d05c91 cee372b ce81e14 bf2ed00 ce81e14 90fec3d ce81e14 90fec3d ce81e14 90fec3d ce81e14 bf2ed00 ce81e14 bf2ed00 ce81e14 90fec3d ce81e14 bf2ed00 ce81e14 bf2ed00 cee372b ce81e14 90fec3d ce81e14 bf2ed00 ce81e14 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
import json
import random
import gradio as gr
import base64
# Load JSON dataset
with open("gita_techies_18_chapters.json", "r", encoding="utf-8") as f:
gita_for_techies = json.load(f)
# Encode background image
with open("bg.png", "rb") as img_file:
b64_bg_img = base64.b64encode(img_file.read()).decode()
# Function to return one random entry
def get_gita_tech():
entry = random.choice(gita_for_techies)
return f"""
<div class="content">
<h2>📘 Chapter {entry["chapter_number"]}</h2>
<p><b>🌼 Spiritual Meaning (EN):</b><br>{entry["spiritual_meaning_en"]}</p>
<p><b>🪔 ఆధ్యాత్మిక అర్థం (TE):</b><br>{entry["spiritual_meaning_te"]}</p>
<p><b>💻 Tech Meaning (EN):</b><br>{entry["tech_meaning_en"]}</p>
<p><b>🌾 టెక్ అర్థం (TE):</b><br>{entry["tech_meaning_te"]}</p>
<p><b>🧠 Lesson for Techies:</b><br>{entry["lesson_for_techies"]}</p>
<p><b>⚙️ Tech Stack Analogy:</b><br>{entry["tech_stack_analogy"]}</p>
<p><b>🧘 Daily Reminder (EN):</b><br><i>{entry["daily_reminder_en"]}</i></p>
<p><b>🧘 రోజువారీ స్మరణ (TE):</b><br><i>{entry["daily_reminder_te"]}</i></p>
<p><b>🧾 Code Snippet:</b></p>
<pre><code>{entry["code_snippet"]}</code></pre>
<hr style="margin-top: 30px;">
<p style="text-align:center;font-size:0.9rem;">🌸 Made with 💜 by <b>Sreelekha Putta</b></p>
</div>
<style>
.content {{
background: rgba(80, 60, 120, 0.3);
padding: 20px;
border-radius: 16px;
max-width: 800px;
width: 92%;
margin: 0 auto 30px auto;
box-shadow: 0 0 30px rgba(200, 150, 255, 0.3);
font-family: 'Segoe UI', sans-serif;
font-size: 1rem;
line-height: 1.8;
word-wrap: break-word;
overflow-wrap: break-word;
text-shadow: 1px 1px 4px rgba(0, 0, 0, 1);
color: #ffffff !important;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}}
.content * {{
color: #ffffff !important;
text-shadow: 1px 1px 4px rgba(0, 0, 0, 1);
}}
h2 {{
font-size: 1.5rem;
margin-bottom: 16px;
color: #d9b2ff;
}}
pre, code {{
background: #1b1b30;
color: #e6f1ff !important;
padding: 12px;
border-radius: 8px;
font-size: 0.95rem;
overflow-x: auto;
box-shadow: 0 0 6px rgba(255,255,255,0.08);
text-shadow: none;
}}
</style>
"""
# CSS with background
css = f"""
body {{
margin: 0;
padding: 0;
min-height: 100vh;
background-image: url("data:image/png;base64,{b64_bg_img}");
background-size: cover;
background-position: center;
background-repeat: no-repeat;
background-attachment: fixed;
font-family: 'Segoe UI', sans-serif;
}}
body::before {{
content: "";
position: fixed;
inset: 0;
background: rgba(0,0,30,0.7);
z-index: -1;
}}
h1 {{
text-align: center;
color: #e7c1ff;
font-size: 2.8rem;
font-weight: 700;
margin: 30px 0 20px 0;
text-shadow: 0 0 15px #c084fc;
}}
button {{
background-color: #a855f7;
border-radius: 12px;
color: white;
font-weight: 600;
font-size: 1.3rem;
padding: 0.8rem 2.4rem;
border: none;
cursor: pointer;
margin-bottom: 30px;
box-shadow: 0 0 18px #a78bfa88;
}}
button:hover {{
background-color: #d8b4fe;
color: black;
box-shadow: 0 0 25px #f0d0ff;
}}
"""
# Gradio interface
with gr.Blocks(css=css) as app:
gr.Markdown("<h1>💻 Bhagavad Gita for Techies 💻</h1>")
output = gr.HTML()
btn = gr.Button("🔁 Get Wisdom Tip")
btn.click(fn=get_gita_tech, outputs=output)
app.launch()
|