Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,52 +1,39 @@
|
|
1 |
-
# Step 1: Install Gradio
|
2 |
-
|
3 |
-
# Step 2: Upload JSON and bg.png files
|
4 |
-
from google.colab import files
|
5 |
-
uploaded = files.upload() # Upload: gita_techies_18_chapters.json + bg.png
|
6 |
-
|
7 |
import json
|
8 |
import random
|
9 |
import gradio as gr
|
10 |
import base64
|
11 |
|
12 |
-
#
|
13 |
with open("gita_techies_18_chapters.json", "r", encoding="utf-8") as f:
|
14 |
gita_for_techies = json.load(f)
|
15 |
|
16 |
-
#
|
17 |
with open("bg.png", "rb") as img_file:
|
18 |
b64_bg_img = base64.b64encode(img_file.read()).decode()
|
19 |
|
20 |
-
#
|
21 |
def get_gita_tech():
|
22 |
entry = random.choice(gita_for_techies)
|
23 |
return f"""
|
24 |
<div class="content">
|
25 |
<h2>📘 Chapter {entry["chapter_number"]}</h2>
|
26 |
-
|
27 |
<p><b>🌼 Spiritual Meaning (EN):</b><br>{entry["spiritual_meaning_en"]}</p>
|
28 |
<p><b>🪔 ఆధ్యాత్మిక అర్థం (TE):</b><br>{entry["spiritual_meaning_te"]}</p>
|
29 |
-
|
30 |
<p><b>💻 Tech Meaning (EN):</b><br>{entry["tech_meaning_en"]}</p>
|
31 |
<p><b>🌾 టెక్ అర్థం (TE):</b><br>{entry["tech_meaning_te"]}</p>
|
32 |
-
|
33 |
<p><b>🧠 Lesson for Techies:</b><br>{entry["lesson_for_techies"]}</p>
|
34 |
<p><b>⚙️ Tech Stack Analogy:</b><br>{entry["tech_stack_analogy"]}</p>
|
35 |
-
|
36 |
<p><b>🧘 Daily Reminder (EN):</b><br><i>{entry["daily_reminder_en"]}</i></p>
|
37 |
<p><b>🧘 రోజువారీ స్మరణ (TE):</b><br><i>{entry["daily_reminder_te"]}</i></p>
|
38 |
-
|
39 |
<p><b>🧾 Code Snippet:</b></p>
|
40 |
<pre><code>{entry["code_snippet"]}</code></pre>
|
41 |
-
|
42 |
<hr style="margin-top: 30px;">
|
43 |
<p style="text-align:center;font-size:0.9rem;">🪷 Made with 💜 by <b>Sreelekha Putta</b></p>
|
44 |
</div>
|
45 |
-
|
46 |
<style>
|
47 |
.content {{
|
48 |
background: rgba(20, 15, 35, 0.9);
|
49 |
-
padding: 25px
|
50 |
border-radius: 16px;
|
51 |
max-width: 800px;
|
52 |
margin: 0 auto 30px auto;
|
@@ -55,11 +42,6 @@ def get_gita_tech():
|
|
55 |
font-family: 'Segoe UI', sans-serif;
|
56 |
animation: fadeIn 1.5s ease forwards;
|
57 |
}}
|
58 |
-
h2 {{
|
59 |
-
color: #d0a8ff;
|
60 |
-
font-family: Georgia, serif;
|
61 |
-
margin-bottom: 16px;
|
62 |
-
}}
|
63 |
pre {{
|
64 |
background: #1f2937;
|
65 |
color: #a5f3fc;
|
@@ -68,14 +50,17 @@ def get_gita_tech():
|
|
68 |
font-size: 0.95rem;
|
69 |
overflow-x: auto;
|
70 |
}}
|
|
|
|
|
|
|
71 |
@keyframes fadeIn {{
|
72 |
-
from {{opacity: 0; transform: translateY(20px);}}
|
73 |
-
to {{opacity: 1; transform: translateY(0);}}
|
74 |
}}
|
75 |
</style>
|
76 |
"""
|
77 |
|
78 |
-
#
|
79 |
css = f"""
|
80 |
body {{
|
81 |
margin: 0;
|
@@ -86,10 +71,6 @@ body {{
|
|
86 |
background-position: center;
|
87 |
background-repeat: no-repeat;
|
88 |
background-attachment: fixed;
|
89 |
-
display: flex;
|
90 |
-
flex-direction: column;
|
91 |
-
align-items: center;
|
92 |
-
justify-content: flex-start;
|
93 |
font-family: 'Segoe UI', sans-serif;
|
94 |
}}
|
95 |
body::before {{
|
@@ -102,10 +83,9 @@ body::before {{
|
|
102 |
h1 {{
|
103 |
text-align: center;
|
104 |
color: #e7c1ff;
|
105 |
-
|
106 |
-
font-family: Georgia, serif;
|
107 |
font-weight: 700;
|
108 |
-
|
109 |
text-shadow: 0 0 15px #c084fc;
|
110 |
}}
|
111 |
button {{
|
@@ -117,9 +97,8 @@ button {{
|
|
117 |
padding: 0.8rem 2.4rem;
|
118 |
border: none;
|
119 |
cursor: pointer;
|
120 |
-
box-shadow: 0 0 18px #a78bfa88;
|
121 |
-
transition: 0.3s ease;
|
122 |
margin-bottom: 30px;
|
|
|
123 |
}}
|
124 |
button:hover {{
|
125 |
background-color: #d8b4fe;
|
@@ -128,7 +107,7 @@ button:hover {{
|
|
128 |
}}
|
129 |
"""
|
130 |
|
131 |
-
#
|
132 |
with gr.Blocks(css=css) as app:
|
133 |
gr.Markdown("<h1>💻 Bhagavad Gita for Techies 💻</h1>")
|
134 |
output = gr.HTML()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import json
|
2 |
import random
|
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 |
+
# ✅ Encode bg.png as base64
|
11 |
with open("bg.png", "rb") as img_file:
|
12 |
b64_bg_img = base64.b64encode(img_file.read()).decode()
|
13 |
|
14 |
+
# ✅ Wisdom generator
|
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;">🪷 Made with 💜 by <b>Sreelekha Putta</b></p>
|
32 |
</div>
|
|
|
33 |
<style>
|
34 |
.content {{
|
35 |
background: rgba(20, 15, 35, 0.9);
|
36 |
+
padding: 25px;
|
37 |
border-radius: 16px;
|
38 |
max-width: 800px;
|
39 |
margin: 0 auto 30px auto;
|
|
|
42 |
font-family: 'Segoe UI', sans-serif;
|
43 |
animation: fadeIn 1.5s ease forwards;
|
44 |
}}
|
|
|
|
|
|
|
|
|
|
|
45 |
pre {{
|
46 |
background: #1f2937;
|
47 |
color: #a5f3fc;
|
|
|
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 |
+
# ✅ CSS with background image
|
64 |
css = f"""
|
65 |
body {{
|
66 |
margin: 0;
|
|
|
71 |
background-position: center;
|
72 |
background-repeat: no-repeat;
|
73 |
background-attachment: fixed;
|
|
|
|
|
|
|
|
|
74 |
font-family: 'Segoe UI', sans-serif;
|
75 |
}}
|
76 |
body::before {{
|
|
|
83 |
h1 {{
|
84 |
text-align: center;
|
85 |
color: #e7c1ff;
|
86 |
+
font-size: 2.5rem;
|
|
|
87 |
font-weight: 700;
|
88 |
+
margin-bottom: 20px;
|
89 |
text-shadow: 0 0 15px #c084fc;
|
90 |
}}
|
91 |
button {{
|
|
|
97 |
padding: 0.8rem 2.4rem;
|
98 |
border: none;
|
99 |
cursor: pointer;
|
|
|
|
|
100 |
margin-bottom: 30px;
|
101 |
+
box-shadow: 0 0 18px #a78bfa88;
|
102 |
}}
|
103 |
button:hover {{
|
104 |
background-color: #d8b4fe;
|
|
|
107 |
}}
|
108 |
"""
|
109 |
|
110 |
+
# ✅ Build UI
|
111 |
with gr.Blocks(css=css) as app:
|
112 |
gr.Markdown("<h1>💻 Bhagavad Gita for Techies 💻</h1>")
|
113 |
output = gr.HTML()
|