Kubratech3 commited on
Commit
d6c1db9
Β·
verified Β·
1 Parent(s): 3e8013c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +64 -10
app.py CHANGED
@@ -22,7 +22,7 @@ client = Groq(api_key=api_key)
22
  def generate_roadmap(domain, level, time):
23
 
24
  if not domain or not time:
25
- return "❌ Please fill all fields."
26
 
27
  prompt = f"""
28
  Create a detailed learning roadmap.
@@ -52,7 +52,6 @@ Include:
52
 
53
  result = response.choices[0].message.content
54
 
55
- # Return for display + for PDF
56
  return result, result
57
 
58
  except Exception as e:
@@ -92,7 +91,7 @@ def create_pdf(text):
92
 
93
  c.drawText(text_obj)
94
 
95
- # Footer in PDF
96
  c.setFont("Helvetica-Bold", 10)
97
  c.drawCentredString(width / 2, 20, "Made by Kubra 🌻")
98
 
@@ -110,6 +109,61 @@ html, body {
110
  padding: 0;
111
  font-family: Arial, sans-serif;
112
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  """
114
 
115
 
@@ -136,10 +190,11 @@ with gr.Blocks(css=custom_css) as app:
136
 
137
  generate_btn = gr.Button("✨ Generate Roadmap")
138
 
139
- output_md = gr.Markdown()
140
- output_text = gr.Textbox(visible=False) # Hidden for PDF
141
 
142
  pdf_btn = gr.Button("πŸ“₯ Download as PDF")
 
143
  pdf_file = gr.File(label="Download PDF")
144
 
145
 
@@ -147,14 +202,13 @@ with gr.Blocks(css=custom_css) as app:
147
  generate_btn.click(
148
  generate_roadmap,
149
  inputs=[domain, level, time],
150
- outputs=[output_md, output_text]
151
  )
152
 
153
-
154
  # Generate PDF
155
  pdf_btn.click(
156
  create_pdf,
157
- inputs=output_text,
158
  outputs=pdf_file
159
  )
160
 
@@ -163,8 +217,8 @@ with gr.Blocks(css=custom_css) as app:
163
  gr.Markdown(
164
  """
165
  ---
166
- **Made by Kubra** 🌻
167
-
168
  """
169
  )
170
 
 
22
  def generate_roadmap(domain, level, time):
23
 
24
  if not domain or not time:
25
+ return "❌ Please fill all fields.", "❌ Please fill all fields."
26
 
27
  prompt = f"""
28
  Create a detailed learning roadmap.
 
52
 
53
  result = response.choices[0].message.content
54
 
 
55
  return result, result
56
 
57
  except Exception as e:
 
91
 
92
  c.drawText(text_obj)
93
 
94
+ # Footer
95
  c.setFont("Helvetica-Bold", 10)
96
  c.drawCentredString(width / 2, 20, "Made by Kubra 🌻")
97
 
 
109
  padding: 0;
110
  font-family: Arial, sans-serif;
111
  }
112
+
113
+ /* Light Mode */
114
+ @media (prefers-color-scheme: light) {
115
+ html,
116
+ body,
117
+ .gradio-container {
118
+ background: linear-gradient(to right, #dff5e3, #b7e4c7) !important;
119
+ color: #1a1a1a !important;
120
+ }
121
+
122
+ input, textarea, select {
123
+ background: #f6fff8 !important;
124
+ color: #1a1a1a !important;
125
+ border: 1px solid #9dd9b1 !important;
126
+ border-radius: 6px;
127
+ }
128
+
129
+ button {
130
+ background: #6fcf97 !important;
131
+ color: #103822 !important;
132
+ border-radius: 8px !important;
133
+ font-weight: 600;
134
+ }
135
+
136
+ button:hover {
137
+ background: #5bbd84 !important;
138
+ }
139
+ }
140
+
141
+ /* Dark Mode */
142
+ @media (prefers-color-scheme: dark) {
143
+ html,
144
+ body,
145
+ .gradio-container {
146
+ background: linear-gradient(to right, #667eea, #764ba2) !important;
147
+ color: white !important;
148
+ }
149
+
150
+ input, textarea, select {
151
+ background: #1e1e2f !important;
152
+ color: white !important;
153
+ border: 1px solid #444 !important;
154
+ }
155
+
156
+ button {
157
+ background: #7c83fd !important;
158
+ color: white !important;
159
+ border-radius: 8px !important;
160
+ font-weight: 600;
161
+ }
162
+
163
+ button:hover {
164
+ background: #6a70e0 !important;
165
+ }
166
+ }
167
  """
168
 
169
 
 
190
 
191
  generate_btn = gr.Button("✨ Generate Roadmap")
192
 
193
+ output = gr.Markdown()
194
+ hidden_text = gr.Textbox(visible=False)
195
 
196
  pdf_btn = gr.Button("πŸ“₯ Download as PDF")
197
+
198
  pdf_file = gr.File(label="Download PDF")
199
 
200
 
 
202
  generate_btn.click(
203
  generate_roadmap,
204
  inputs=[domain, level, time],
205
+ outputs=[output, hidden_text]
206
  )
207
 
 
208
  # Generate PDF
209
  pdf_btn.click(
210
  create_pdf,
211
+ inputs=hidden_text,
212
  outputs=pdf_file
213
  )
214
 
 
217
  gr.Markdown(
218
  """
219
  ---
220
+ 🌻 **Made by Kubra** 🌻
221
+ Powered by AI β€’ Keep Learning πŸš€
222
  """
223
  )
224