Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -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,62 +34,49 @@ 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 |
max-width: 800px;
|
| 46 |
-
margin: 0 auto
|
| 47 |
box-shadow: 0 0 20px #ab71f7;
|
| 48 |
color: #ffffff !important;
|
| 49 |
font-family: 'Segoe UI', sans-serif;
|
| 50 |
-
animation: fadeIn 1.5s ease forwards;
|
| 51 |
text-shadow: 1px 1px 6px rgba(0, 0, 0, 1);
|
| 52 |
word-wrap: break-word;
|
| 53 |
overflow-wrap: break-word;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
}}
|
| 55 |
pre {{
|
| 56 |
background: #0e0e23;
|
| 57 |
color: #e0f2fe;
|
| 58 |
-
padding:
|
| 59 |
-
border-radius:
|
| 60 |
-
font-size:
|
| 61 |
overflow-x: auto;
|
| 62 |
box-shadow: 0 0 10px rgba(255,255,255,0.1);
|
| 63 |
text-shadow: none;
|
| 64 |
}}
|
| 65 |
-
@keyframes fadeIn {{
|
| 66 |
-
from {{opacity: 0; transform: translateY(20px);}}
|
| 67 |
-
to {{opacity: 1; transform: translateY(0);}}
|
| 68 |
-
}}
|
| 69 |
-
@media screen and (max-width: 600px) {{
|
| 70 |
-
.content {{
|
| 71 |
-
padding: 14px;
|
| 72 |
-
font-size: 0.94rem;
|
| 73 |
-
line-height: 1.6;
|
| 74 |
-
}}
|
| 75 |
-
h2 {{
|
| 76 |
-
font-size: 1.5rem;
|
| 77 |
-
}}
|
| 78 |
-
pre {{
|
| 79 |
-
font-size: 0.85rem;
|
| 80 |
-
}}
|
| 81 |
-
body {{
|
| 82 |
-
padding: 10px;
|
| 83 |
-
}}
|
| 84 |
-
}}
|
| 85 |
</style>
|
| 86 |
"""
|
| 87 |
|
| 88 |
-
# CSS
|
| 89 |
css = f"""
|
| 90 |
body {{
|
| 91 |
margin: 0;
|
| 92 |
-
padding:
|
| 93 |
min-height: 100vh;
|
| 94 |
background-image: url("data:image/png;base64,{b64_bg_img}");
|
| 95 |
background-size: cover;
|
|
@@ -98,6 +85,7 @@ body {{
|
|
| 98 |
background-attachment: fixed;
|
| 99 |
font-family: 'Segoe UI', sans-serif;
|
| 100 |
}}
|
|
|
|
| 101 |
body::before {{
|
| 102 |
content: "";
|
| 103 |
position: fixed;
|
|
@@ -105,26 +93,29 @@ body::before {{
|
|
| 105 |
background: rgba(0,0,30,0.7);
|
| 106 |
z-index: -1;
|
| 107 |
}}
|
|
|
|
| 108 |
h1 {{
|
| 109 |
text-align: center;
|
| 110 |
color: #e7c1ff;
|
| 111 |
-
font-size:
|
| 112 |
font-weight: 700;
|
| 113 |
-
margin
|
| 114 |
text-shadow: 0 0 15px #c084fc;
|
| 115 |
}}
|
|
|
|
| 116 |
button {{
|
| 117 |
background-color: #a855f7;
|
| 118 |
border-radius: 12px;
|
| 119 |
color: white;
|
| 120 |
font-weight: 600;
|
| 121 |
-
font-size:
|
| 122 |
-
padding:
|
| 123 |
border: none;
|
| 124 |
cursor: pointer;
|
| 125 |
-
margin-bottom:
|
| 126 |
box-shadow: 0 0 18px #a78bfa88;
|
| 127 |
}}
|
|
|
|
| 128 |
button:hover {{
|
| 129 |
background-color: #d8b4fe;
|
| 130 |
color: black;
|
|
@@ -132,7 +123,7 @@ button:hover {{
|
|
| 132 |
}}
|
| 133 |
"""
|
| 134 |
|
| 135 |
-
# Gradio
|
| 136 |
with gr.Blocks(css=css) as app:
|
| 137 |
gr.Markdown("<h1>π» Bhagavad Gita for Techies π»</h1>")
|
| 138 |
output = gr.HTML()
|
|
|
|
| 11 |
with open("bg.png", "rb") as img_file:
|
| 12 |
b64_bg_img = base64.b64encode(img_file.read()).decode()
|
| 13 |
|
| 14 |
+
# Function to display one 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:3.5vw;">πΈ 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: 5vw;
|
| 44 |
+
border-radius: 5vw;
|
| 45 |
+
width: 92vw;
|
| 46 |
max-width: 800px;
|
| 47 |
+
margin: 0 auto 6vw auto;
|
| 48 |
box-shadow: 0 0 20px #ab71f7;
|
| 49 |
color: #ffffff !important;
|
| 50 |
font-family: 'Segoe UI', sans-serif;
|
|
|
|
| 51 |
text-shadow: 1px 1px 6px rgba(0, 0, 0, 1);
|
| 52 |
word-wrap: break-word;
|
| 53 |
overflow-wrap: break-word;
|
| 54 |
+
font-size: 4vw;
|
| 55 |
+
line-height: 1.7;
|
| 56 |
+
}}
|
| 57 |
+
.content h2 {{
|
| 58 |
+
font-size: 5.5vw;
|
| 59 |
+
margin-bottom: 4vw;
|
| 60 |
+
color: #d9b2ff;
|
| 61 |
}}
|
| 62 |
pre {{
|
| 63 |
background: #0e0e23;
|
| 64 |
color: #e0f2fe;
|
| 65 |
+
padding: 3vw;
|
| 66 |
+
border-radius: 3vw;
|
| 67 |
+
font-size: 3.5vw;
|
| 68 |
overflow-x: auto;
|
| 69 |
box-shadow: 0 0 10px rgba(255,255,255,0.1);
|
| 70 |
text-shadow: none;
|
| 71 |
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
</style>
|
| 73 |
"""
|
| 74 |
|
| 75 |
+
# CSS block
|
| 76 |
css = f"""
|
| 77 |
body {{
|
| 78 |
margin: 0;
|
| 79 |
+
padding: 0;
|
| 80 |
min-height: 100vh;
|
| 81 |
background-image: url("data:image/png;base64,{b64_bg_img}");
|
| 82 |
background-size: cover;
|
|
|
|
| 85 |
background-attachment: fixed;
|
| 86 |
font-family: 'Segoe UI', sans-serif;
|
| 87 |
}}
|
| 88 |
+
|
| 89 |
body::before {{
|
| 90 |
content: "";
|
| 91 |
position: fixed;
|
|
|
|
| 93 |
background: rgba(0,0,30,0.7);
|
| 94 |
z-index: -1;
|
| 95 |
}}
|
| 96 |
+
|
| 97 |
h1 {{
|
| 98 |
text-align: center;
|
| 99 |
color: #e7c1ff;
|
| 100 |
+
font-size: 6vw;
|
| 101 |
font-weight: 700;
|
| 102 |
+
margin: 6vw 4vw 4vw 4vw;
|
| 103 |
text-shadow: 0 0 15px #c084fc;
|
| 104 |
}}
|
| 105 |
+
|
| 106 |
button {{
|
| 107 |
background-color: #a855f7;
|
| 108 |
border-radius: 12px;
|
| 109 |
color: white;
|
| 110 |
font-weight: 600;
|
| 111 |
+
font-size: 4.5vw;
|
| 112 |
+
padding: 3vw 7vw;
|
| 113 |
border: none;
|
| 114 |
cursor: pointer;
|
| 115 |
+
margin-bottom: 6vw;
|
| 116 |
box-shadow: 0 0 18px #a78bfa88;
|
| 117 |
}}
|
| 118 |
+
|
| 119 |
button:hover {{
|
| 120 |
background-color: #d8b4fe;
|
| 121 |
color: black;
|
|
|
|
| 123 |
}}
|
| 124 |
"""
|
| 125 |
|
| 126 |
+
# Gradio app
|
| 127 |
with gr.Blocks(css=css) as app:
|
| 128 |
gr.Markdown("<h1>π» Bhagavad Gita for Techies π»</h1>")
|
| 129 |
output = gr.HTML()
|