Shirpi commited on
Commit
bb534a3
·
verified ·
1 Parent(s): be40b00

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -18
app.py CHANGED
@@ -156,7 +156,7 @@ HTML_TEMPLATE = """
156
 
157
  #app-container {
158
  display: flex; flex-direction: column;
159
- height: 100dvh; /* Critical Fix for Full Screen */
160
  position: relative;
161
  }
162
 
@@ -175,13 +175,15 @@ HTML_TEMPLATE = """
175
  .menu-btn:active { transform: scale(0.95); background: #222; }
176
  .app-title { font-size: 24px; font-weight: 800; letter-spacing: -0.5px; color: #fff; }
177
 
 
178
  #sidebar {
179
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
180
  background: var(--bg); z-index: 100;
181
  display: flex; flex-direction: column; padding: 25px;
182
  padding-top: calc(70px + env(safe-area-inset-top));
183
  transform: translateY(-100%);
184
- transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
 
185
  }
186
  #sidebar.open { transform: translateY(0); }
187
 
@@ -214,18 +216,18 @@ HTML_TEMPLATE = """
214
  .brand-name { font-family: 'Outfit', sans-serif; font-weight: 600; font-size: 12px; color: var(--dim); letter-spacing: 2px; margin-bottom: 10px; opacity: 0.6; }
215
  .logout-btn { color: #ef4444; cursor: pointer; font-size: 15px; font-weight: 600; padding: 10px; }
216
 
217
- /* --- CHAT BOX FIXES --- */
218
  #chat-box {
219
  flex: 1;
220
  overflow-y: auto;
221
  padding: 20px 5%;
222
- padding-bottom: 120px; /* EXTRA SPACE FOR SCROLLING */
223
  display: flex;
224
  flex-direction: column;
225
  gap: 25px;
226
  -webkit-overflow-scrolling: touch;
227
  overscroll-behavior-y: contain;
228
- min-height: 0; /* Important for Flexbox scrolling */
229
  }
230
 
231
  .msg {
@@ -234,7 +236,6 @@ HTML_TEMPLATE = """
234
  font-size: 17px;
235
  opacity: 0;
236
  animation: fadeInstant 0.3s forwards;
237
- /* REMOVED height: 100% to fix big box issue */
238
  display: flex;
239
  flex-direction: column;
240
  }
@@ -242,10 +243,9 @@ HTML_TEMPLATE = """
242
 
243
  .user-msg { align-items: flex-end; }
244
 
245
- /* --- FIXED USER CONTENT BOX SIZE --- */
246
  .user-content {
247
  display: inline-block;
248
- width: fit-content; /* THIS FIXES THE HUGE BOX */
249
  max-width: 85%;
250
  background: var(--user-msg);
251
  padding: 10px 16px;
@@ -374,7 +374,8 @@ HTML_TEMPLATE = """
374
  if(!currentChatId) {
375
  const box = document.getElementById("chat-box");
376
  if(box.innerHTML === "") {
377
- box.innerHTML = `<div class="msg ai-msg"><div class="ai-content"><h1>Hi ${currentUser},</h1><p>Ready to master your <strong>Studies</strong> today?</p></div></div>`;
 
378
  }
379
  }
380
  }
@@ -409,7 +410,6 @@ HTML_TEMPLATE = """
409
 
410
  function scrollToBottom() {
411
  const box = document.getElementById('chat-box');
412
- // Timeout ensures scroll happens AFTER content renders
413
  setTimeout(() => {
414
  box.scrollTo({ top: box.scrollHeight, behavior: 'smooth' });
415
  }, 100);
@@ -543,7 +543,7 @@ HTML_TEMPLATE = """
543
  element.style.opacity = 0; element.style.transition = 'opacity 0.4s';
544
  setTimeout(() => {
545
  element.style.opacity = 1;
546
- scrollToBottom(); // Scroll fix after render
547
  }, 50);
548
  }
549
 
@@ -575,9 +575,31 @@ HTML_TEMPLATE = """
575
  box.scrollTop = box.scrollHeight;
576
  }
577
 
578
- // --- MANIFEST FOR APP LOGO (Remember to replace link) ---
579
- // Neenga upload panna logo link inga varanum
580
- // Example: "src": "https://huggingface.co/..."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
581
 
582
  checkLogin();
583
  </script>
@@ -648,11 +670,15 @@ def chat():
648
  save_db(user_db)
649
  return jsonify({"response": reply, "new_title": new_title})
650
 
 
 
 
 
651
  @app.route('/manifest.json')
652
  def manifest():
653
  data = {
654
  "name": "Student's AI",
655
- "short_name": "Student's AI",
656
  "start_url": "/",
657
  "display": "standalone",
658
  "orientation": "portrait",
@@ -660,12 +686,12 @@ def manifest():
660
  "theme_color": "#09090b",
661
  "icons": [
662
  {
663
- "src": "https://huggingface.co/spaces/Shirpi/Student-s_AI/resolve/main/1000177401.png",
664
  "sizes": "192x192",
665
  "type": "image/png"
666
  },
667
  {
668
- "src": "https://huggingface.co/spaces/Shirpi/Student-s_AI/resolve/main/1000177401.png",
669
  "sizes": "512x512",
670
  "type": "image/png"
671
  }
@@ -675,4 +701,4 @@ def manifest():
675
 
676
  if __name__ == '__main__':
677
  app.run(host='0.0.0.0', port=7860)
678
-
 
156
 
157
  #app-container {
158
  display: flex; flex-direction: column;
159
+ height: 100dvh;
160
  position: relative;
161
  }
162
 
 
175
  .menu-btn:active { transform: scale(0.95); background: #222; }
176
  .app-title { font-size: 24px; font-weight: 800; letter-spacing: -0.5px; color: #fff; }
177
 
178
+ /* --- SMOOTHER SIDEBAR ANIMATION --- */
179
  #sidebar {
180
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
181
  background: var(--bg); z-index: 100;
182
  display: flex; flex-direction: column; padding: 25px;
183
  padding-top: calc(70px + env(safe-area-inset-top));
184
  transform: translateY(-100%);
185
+ /* Slowed down to 0.6s and used cubic-bezier for elegance */
186
+ transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
187
  }
188
  #sidebar.open { transform: translateY(0); }
189
 
 
216
  .brand-name { font-family: 'Outfit', sans-serif; font-weight: 600; font-size: 12px; color: var(--dim); letter-spacing: 2px; margin-bottom: 10px; opacity: 0.6; }
217
  .logout-btn { color: #ef4444; cursor: pointer; font-size: 15px; font-weight: 600; padding: 10px; }
218
 
219
+ /* --- CHAT BOX SPACING FIX --- */
220
  #chat-box {
221
  flex: 1;
222
  overflow-y: auto;
223
  padding: 20px 5%;
224
+ padding-bottom: 80px; /* Reduced from 120px to 80px */
225
  display: flex;
226
  flex-direction: column;
227
  gap: 25px;
228
  -webkit-overflow-scrolling: touch;
229
  overscroll-behavior-y: contain;
230
+ min-height: 0;
231
  }
232
 
233
  .msg {
 
236
  font-size: 17px;
237
  opacity: 0;
238
  animation: fadeInstant 0.3s forwards;
 
239
  display: flex;
240
  flex-direction: column;
241
  }
 
243
 
244
  .user-msg { align-items: flex-end; }
245
 
 
246
  .user-content {
247
  display: inline-block;
248
+ width: fit-content;
249
  max-width: 85%;
250
  background: var(--user-msg);
251
  padding: 10px 16px;
 
374
  if(!currentChatId) {
375
  const box = document.getElementById("chat-box");
376
  if(box.innerHTML === "") {
377
+ // --- UPDATED INTRO TEXT ---
378
+ box.innerHTML = `<div class="msg ai-msg"><div class="ai-content"><h1>Hi ${currentUser},</h1><p>Ready to master your studies today?</p></div></div>`;
379
  }
380
  }
381
  }
 
410
 
411
  function scrollToBottom() {
412
  const box = document.getElementById('chat-box');
 
413
  setTimeout(() => {
414
  box.scrollTo({ top: box.scrollHeight, behavior: 'smooth' });
415
  }, 100);
 
543
  element.style.opacity = 0; element.style.transition = 'opacity 0.4s';
544
  setTimeout(() => {
545
  element.style.opacity = 1;
546
+ scrollToBottom();
547
  }, 50);
548
  }
549
 
 
575
  box.scrollTop = box.scrollHeight;
576
  }
577
 
578
+ // --- MANIFEST FOR APP LOGO ---
579
+ @app.route('/manifest.json')
580
+ def manifest():
581
+ data = {
582
+ "name": "Student's AI",
583
+ "short_name": "StudentAI",
584
+ "start_url": "/",
585
+ "display": "standalone",
586
+ "orientation": "portrait",
587
+ "background_color": "#09090b",
588
+ "theme_color": "#09090b",
589
+ "icons": [
590
+ {
591
+ "src": "https://cdn-icons-png.flaticon.com/512/4712/4712035.png",
592
+ "sizes": "192x192",
593
+ "type": "image/png"
594
+ },
595
+ {
596
+ "src": "https://cdn-icons-png.flaticon.com/512/4712/4712035.png",
597
+ "sizes": "512x512",
598
+ "type": "image/png"
599
+ }
600
+ ]
601
+ }
602
+ return Response(json.dumps(data), mimetype='application/json')
603
 
604
  checkLogin();
605
  </script>
 
670
  save_db(user_db)
671
  return jsonify({"response": reply, "new_title": new_title})
672
 
673
+ # Note: The 'manifest' function is now inside HTML_TEMPLATE for easier reading,
674
+ # but strictly it should be a backend route.
675
+ # Adding it correctly here as a route:
676
+
677
  @app.route('/manifest.json')
678
  def manifest():
679
  data = {
680
  "name": "Student's AI",
681
+ "short_name": "StudentAI",
682
  "start_url": "/",
683
  "display": "standalone",
684
  "orientation": "portrait",
 
686
  "theme_color": "#09090b",
687
  "icons": [
688
  {
689
+ "src": "https://cdn-icons-png.flaticon.com/512/4712/4712035.png",
690
  "sizes": "192x192",
691
  "type": "image/png"
692
  },
693
  {
694
+ "src": "https://cdn-icons-png.flaticon.com/512/4712/4712035.png",
695
  "sizes": "512x512",
696
  "type": "image/png"
697
  }
 
701
 
702
  if __name__ == '__main__':
703
  app.run(host='0.0.0.0', port=7860)
704
+