Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ import random
|
|
3 |
import gradio as gr
|
4 |
import base64
|
5 |
|
6 |
-
# Load JSON
|
7 |
with open("gita_techies_18_chapters.json", "r", encoding="utf-8") as f:
|
8 |
gita_for_techies = json.load(f)
|
9 |
|
@@ -11,7 +11,7 @@ with open("gita_techies_18_chapters.json", "r", encoding="utf-8") as f:
|
|
11 |
with open("bg.png", "rb") as img_file:
|
12 |
b64_bg_img = base64.b64encode(img_file.read()).decode()
|
13 |
|
14 |
-
# Function to
|
15 |
def get_gita_tech():
|
16 |
entry = random.choice(gita_for_techies)
|
17 |
return f"""
|
@@ -34,37 +34,39 @@ def get_gita_tech():
|
|
34 |
<pre><code>{entry["code_snippet"]}</code></pre>
|
35 |
|
36 |
<hr style="margin-top: 30px;">
|
37 |
-
<p style="text-align:center;font-size:
|
38 |
</div>
|
39 |
|
40 |
<style>
|
41 |
.content {{
|
42 |
background: rgba(20, 15, 35, 0.92);
|
43 |
-
padding:
|
44 |
-
border-radius:
|
45 |
-
width: 92vw;
|
46 |
max-width: 800px;
|
47 |
-
|
48 |
-
|
|
|
49 |
color: #ffffff !important;
|
50 |
font-family: 'Segoe UI', sans-serif;
|
51 |
-
|
|
|
52 |
word-wrap: break-word;
|
53 |
overflow-wrap: break-word;
|
54 |
-
|
55 |
-
|
|
|
56 |
}}
|
57 |
-
|
58 |
-
font-size:
|
59 |
-
margin-bottom:
|
60 |
color: #d9b2ff;
|
61 |
}}
|
62 |
pre {{
|
63 |
background: #0e0e23;
|
64 |
color: #e0f2fe;
|
65 |
-
padding:
|
66 |
-
border-radius:
|
67 |
-
font-size:
|
68 |
overflow-x: auto;
|
69 |
box-shadow: 0 0 10px rgba(255,255,255,0.1);
|
70 |
text-shadow: none;
|
@@ -72,7 +74,7 @@ def get_gita_tech():
|
|
72 |
</style>
|
73 |
"""
|
74 |
|
75 |
-
# CSS
|
76 |
css = f"""
|
77 |
body {{
|
78 |
margin: 0;
|
@@ -97,9 +99,9 @@ body::before {{
|
|
97 |
h1 {{
|
98 |
text-align: center;
|
99 |
color: #e7c1ff;
|
100 |
-
font-size:
|
101 |
font-weight: 700;
|
102 |
-
margin:
|
103 |
text-shadow: 0 0 15px #c084fc;
|
104 |
}}
|
105 |
|
@@ -108,11 +110,11 @@ button {{
|
|
108 |
border-radius: 12px;
|
109 |
color: white;
|
110 |
font-weight: 600;
|
111 |
-
font-size:
|
112 |
-
padding:
|
113 |
border: none;
|
114 |
cursor: pointer;
|
115 |
-
margin-bottom:
|
116 |
box-shadow: 0 0 18px #a78bfa88;
|
117 |
}}
|
118 |
|
@@ -123,7 +125,7 @@ button:hover {{
|
|
123 |
}}
|
124 |
"""
|
125 |
|
126 |
-
# Gradio
|
127 |
with gr.Blocks(css=css) as app:
|
128 |
gr.Markdown("<h1>π» Bhagavad Gita for Techies π»</h1>")
|
129 |
output = gr.HTML()
|
|
|
3 |
import gradio as gr
|
4 |
import base64
|
5 |
|
6 |
+
# Load JSON dataset
|
7 |
with open("gita_techies_18_chapters.json", "r", encoding="utf-8") as f:
|
8 |
gita_for_techies = json.load(f)
|
9 |
|
|
|
11 |
with open("bg.png", "rb") as img_file:
|
12 |
b64_bg_img = base64.b64encode(img_file.read()).decode()
|
13 |
|
14 |
+
# Function to return one random entry
|
15 |
def get_gita_tech():
|
16 |
entry = random.choice(gita_for_techies)
|
17 |
return f"""
|
|
|
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: 16px;
|
|
|
45 |
max-width: 800px;
|
46 |
+
width: 92%;
|
47 |
+
margin: 0 auto 30px auto;
|
48 |
+
box-shadow: 0 0 25px #ab71f7;
|
49 |
color: #ffffff !important;
|
50 |
font-family: 'Segoe UI', sans-serif;
|
51 |
+
font-size: 1rem;
|
52 |
+
line-height: 1.8;
|
53 |
word-wrap: break-word;
|
54 |
overflow-wrap: break-word;
|
55 |
+
text-shadow: 1px 1px 5px rgba(0, 0, 0, 1);
|
56 |
+
-webkit-font-smoothing: antialiased;
|
57 |
+
-moz-osx-font-smoothing: grayscale;
|
58 |
}}
|
59 |
+
h2 {{
|
60 |
+
font-size: 1.5rem;
|
61 |
+
margin-bottom: 16px;
|
62 |
color: #d9b2ff;
|
63 |
}}
|
64 |
pre {{
|
65 |
background: #0e0e23;
|
66 |
color: #e0f2fe;
|
67 |
+
padding: 12px;
|
68 |
+
border-radius: 8px;
|
69 |
+
font-size: 0.95rem;
|
70 |
overflow-x: auto;
|
71 |
box-shadow: 0 0 10px rgba(255,255,255,0.1);
|
72 |
text-shadow: none;
|
|
|
74 |
</style>
|
75 |
"""
|
76 |
|
77 |
+
# CSS with background
|
78 |
css = f"""
|
79 |
body {{
|
80 |
margin: 0;
|
|
|
99 |
h1 {{
|
100 |
text-align: center;
|
101 |
color: #e7c1ff;
|
102 |
+
font-size: 2.8rem;
|
103 |
font-weight: 700;
|
104 |
+
margin: 30px 0 20px 0;
|
105 |
text-shadow: 0 0 15px #c084fc;
|
106 |
}}
|
107 |
|
|
|
110 |
border-radius: 12px;
|
111 |
color: white;
|
112 |
font-weight: 600;
|
113 |
+
font-size: 1.3rem;
|
114 |
+
padding: 0.8rem 2.4rem;
|
115 |
border: none;
|
116 |
cursor: pointer;
|
117 |
+
margin-bottom: 30px;
|
118 |
box-shadow: 0 0 18px #a78bfa88;
|
119 |
}}
|
120 |
|
|
|
125 |
}}
|
126 |
"""
|
127 |
|
128 |
+
# Gradio interface
|
129 |
with gr.Blocks(css=css) as app:
|
130 |
gr.Markdown("<h1>π» Bhagavad Gita for Techies π»</h1>")
|
131 |
output = gr.HTML()
|