Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,64 +3,82 @@ import random
|
|
3 |
import gradio as gr
|
4 |
import base64
|
5 |
|
6 |
-
#
|
7 |
with open("gita_techies_18_chapters.json", "r", encoding="utf-8") as f:
|
8 |
gita_for_techies = json.load(f)
|
9 |
|
10 |
-
#
|
11 |
with open("bg.png", "rb") as img_file:
|
12 |
b64_bg_img = base64.b64encode(img_file.read()).decode()
|
13 |
|
14 |
-
#
|
15 |
def get_gita_tech():
|
16 |
entry = random.choice(gita_for_techies)
|
17 |
return f"""
|
18 |
<div class="content">
|
19 |
<h2>📘 Chapter {entry["chapter_number"]}</h2>
|
|
|
20 |
<p><b>🌼 Spiritual Meaning (EN):</b><br>{entry["spiritual_meaning_en"]}</p>
|
21 |
<p><b>🪔 ఆధ్యాత్మిక అర్థం (TE):</b><br>{entry["spiritual_meaning_te"]}</p>
|
|
|
22 |
<p><b>💻 Tech Meaning (EN):</b><br>{entry["tech_meaning_en"]}</p>
|
23 |
<p><b>🌾 టెక్ అర్థం (TE):</b><br>{entry["tech_meaning_te"]}</p>
|
|
|
24 |
<p><b>🧠 Lesson for Techies:</b><br>{entry["lesson_for_techies"]}</p>
|
25 |
<p><b>⚙️ Tech Stack Analogy:</b><br>{entry["tech_stack_analogy"]}</p>
|
|
|
26 |
<p><b>🧘 Daily Reminder (EN):</b><br><i>{entry["daily_reminder_en"]}</i></p>
|
27 |
<p><b>🧘 రోజువారీ స్మరణ (TE):</b><br><i>{entry["daily_reminder_te"]}</i></p>
|
|
|
28 |
<p><b>🧾 Code Snippet:</b></p>
|
29 |
<pre><code>{entry["code_snippet"]}</code></pre>
|
|
|
30 |
<hr style="margin-top: 30px;">
|
31 |
-
<p style="text-align:center;font-size:0.9rem;"
|
32 |
</div>
|
|
|
33 |
<style>
|
34 |
.content {{
|
35 |
-
background: rgba(20, 15, 35, 0.
|
36 |
-
padding:
|
37 |
-
border-radius:
|
38 |
max-width: 800px;
|
39 |
margin: 0 auto 30px auto;
|
40 |
-
box-shadow: 0 0
|
41 |
-
color: #
|
42 |
font-family: 'Segoe UI', sans-serif;
|
43 |
animation: fadeIn 1.5s ease forwards;
|
|
|
44 |
}}
|
45 |
pre {{
|
46 |
-
background: #
|
47 |
-
color: #
|
48 |
padding: 12px;
|
49 |
-
border-radius:
|
50 |
font-size: 0.95rem;
|
51 |
overflow-x: auto;
|
52 |
-
|
53 |
-
h2 {{
|
54 |
-
color: #d0a8ff;
|
55 |
}}
|
56 |
@keyframes fadeIn {{
|
57 |
from {{ opacity: 0; transform: translateY(20px); }}
|
58 |
to {{ opacity: 1; transform: translateY(0); }}
|
59 |
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
</style>
|
61 |
"""
|
62 |
|
63 |
-
#
|
64 |
css = f"""
|
65 |
body {{
|
66 |
margin: 0;
|
@@ -107,7 +125,7 @@ button:hover {{
|
|
107 |
}}
|
108 |
"""
|
109 |
|
110 |
-
#
|
111 |
with gr.Blocks(css=css) as app:
|
112 |
gr.Markdown("<h1>💻 Bhagavad Gita for Techies 💻</h1>")
|
113 |
output = gr.HTML()
|
|
|
3 |
import gradio as gr
|
4 |
import base64
|
5 |
|
6 |
+
# Load JSON data
|
7 |
with open("gita_techies_18_chapters.json", "r", encoding="utf-8") as f:
|
8 |
gita_for_techies = json.load(f)
|
9 |
|
10 |
+
# Load and encode bg image
|
11 |
with open("bg.png", "rb") as img_file:
|
12 |
b64_bg_img = base64.b64encode(img_file.read()).decode()
|
13 |
|
14 |
+
# Function to fetch one entry
|
15 |
def get_gita_tech():
|
16 |
entry = random.choice(gita_for_techies)
|
17 |
return f"""
|
18 |
<div class="content">
|
19 |
<h2>📘 Chapter {entry["chapter_number"]}</h2>
|
20 |
+
|
21 |
<p><b>🌼 Spiritual Meaning (EN):</b><br>{entry["spiritual_meaning_en"]}</p>
|
22 |
<p><b>🪔 ఆధ్యాత్మిక అర్థం (TE):</b><br>{entry["spiritual_meaning_te"]}</p>
|
23 |
+
|
24 |
<p><b>💻 Tech Meaning (EN):</b><br>{entry["tech_meaning_en"]}</p>
|
25 |
<p><b>🌾 టెక్ అర్థం (TE):</b><br>{entry["tech_meaning_te"]}</p>
|
26 |
+
|
27 |
<p><b>🧠 Lesson for Techies:</b><br>{entry["lesson_for_techies"]}</p>
|
28 |
<p><b>⚙️ Tech Stack Analogy:</b><br>{entry["tech_stack_analogy"]}</p>
|
29 |
+
|
30 |
<p><b>🧘 Daily Reminder (EN):</b><br><i>{entry["daily_reminder_en"]}</i></p>
|
31 |
<p><b>🧘 రోజువారీ స్మరణ (TE):</b><br><i>{entry["daily_reminder_te"]}</i></p>
|
32 |
+
|
33 |
<p><b>🧾 Code Snippet:</b></p>
|
34 |
<pre><code>{entry["code_snippet"]}</code></pre>
|
35 |
+
|
36 |
<hr style="margin-top: 30px;">
|
37 |
+
<p style="text-align:center;font-size:0.9rem;">🌸 Made with 💜 by <b>Sreelekha Putta</b></p>
|
38 |
</div>
|
39 |
+
|
40 |
<style>
|
41 |
.content {{
|
42 |
+
background: rgba(20, 15, 35, 0.92);
|
43 |
+
padding: 20px;
|
44 |
+
border-radius: 18px;
|
45 |
max-width: 800px;
|
46 |
margin: 0 auto 30px auto;
|
47 |
+
box-shadow: 0 0 20px #ab71f7;
|
48 |
+
color: #ffffff;
|
49 |
font-family: 'Segoe UI', sans-serif;
|
50 |
animation: fadeIn 1.5s ease forwards;
|
51 |
+
text-shadow: 1px 1px 4px rgba(0, 0, 0, 0.6);
|
52 |
}}
|
53 |
pre {{
|
54 |
+
background: #111827;
|
55 |
+
color: #e0f2fe;
|
56 |
padding: 12px;
|
57 |
+
border-radius: 10px;
|
58 |
font-size: 0.95rem;
|
59 |
overflow-x: auto;
|
60 |
+
box-shadow: 0 0 10px rgba(255,255,255,0.08);
|
|
|
|
|
61 |
}}
|
62 |
@keyframes fadeIn {{
|
63 |
from {{ opacity: 0; transform: translateY(20px); }}
|
64 |
to {{ opacity: 1; transform: translateY(0); }}
|
65 |
}}
|
66 |
+
@media screen and (max-width: 600px) {{
|
67 |
+
.content {{
|
68 |
+
padding: 16px;
|
69 |
+
font-size: 0.95rem;
|
70 |
+
}}
|
71 |
+
h2 {{
|
72 |
+
font-size: 1.5rem;
|
73 |
+
}}
|
74 |
+
pre {{
|
75 |
+
font-size: 0.85rem;
|
76 |
+
}}
|
77 |
+
}}
|
78 |
</style>
|
79 |
"""
|
80 |
|
81 |
+
# CSS with responsive background
|
82 |
css = f"""
|
83 |
body {{
|
84 |
margin: 0;
|
|
|
125 |
}}
|
126 |
"""
|
127 |
|
128 |
+
# Gradio app
|
129 |
with gr.Blocks(css=css) as app:
|
130 |
gr.Markdown("<h1>💻 Bhagavad Gita for Techies 💻</h1>")
|
131 |
output = gr.HTML()
|