Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -108,7 +108,7 @@ def generate_with_retry(prompt, image_data=None, file_text=None, history_message
|
|
| 108 |
|
| 109 |
return "⚠️ System Busy. Please try again."
|
| 110 |
|
| 111 |
-
# --- UI TEMPLATE (
|
| 112 |
HTML_TEMPLATE = """
|
| 113 |
<!DOCTYPE html>
|
| 114 |
<html lang="en">
|
|
@@ -306,7 +306,7 @@ HTML_TEMPLATE = """
|
|
| 306 |
<div id="login-overlay">
|
| 307 |
<div class="login-box">
|
| 308 |
<h1 class="app-title" style="margin-bottom:10px;">Student's AI</h1>
|
| 309 |
-
<input type="text" id="username-input" placeholder="Your Name" style="width:100%; padding:15px; border-radius:12px; border:1px solid #333; background:#111; color:#fff; text-align:center; outline:none; margin-bottom:20px; font-size: 16px;">
|
| 310 |
<button onclick="handleLogin()" style="width:100%; padding:15px; border-radius:12px; border:none; background:#fff; font-weight:800; cursor:pointer; font-size: 16px;">Start Learning</button>
|
| 311 |
</div>
|
| 312 |
</div>
|
|
@@ -387,18 +387,21 @@ HTML_TEMPLATE = """
|
|
| 387 |
if(name) {
|
| 388 |
try { localStorage.setItem("student_ai_user", name); } catch(e){}
|
| 389 |
currentUser = name;
|
| 390 |
-
|
|
|
|
|
|
|
|
|
|
| 391 |
showApp();
|
| 392 |
} else {
|
| 393 |
input.style.border = "1px solid red";
|
| 394 |
setTimeout(() => input.style.border = "1px solid #333", 2000);
|
| 395 |
}
|
| 396 |
}
|
| 397 |
-
|
| 398 |
function handleLogout() {
|
| 399 |
try { localStorage.removeItem("student_ai_user"); } catch(e){}
|
| 400 |
const overlay = document.getElementById("login-overlay");
|
| 401 |
-
overlay.
|
|
|
|
| 402 |
document.getElementById('sidebar').classList.remove('open');
|
| 403 |
setTimeout(() => {
|
| 404 |
document.getElementById('chat-box').innerHTML = "";
|
|
@@ -652,34 +655,11 @@ HTML_TEMPLATE = """
|
|
| 652 |
box.scrollTop = box.scrollHeight;
|
| 653 |
}
|
| 654 |
|
| 655 |
-
|
| 656 |
-
|
| 657 |
-
|
| 658 |
-
|
| 659 |
-
|
| 660 |
-
"start_url": "/",
|
| 661 |
-
"display": "standalone",
|
| 662 |
-
"orientation": "portrait",
|
| 663 |
-
"background_color": "#09090b",
|
| 664 |
-
"theme_color": "#09090b",
|
| 665 |
-
"icons": [
|
| 666 |
-
{
|
| 667 |
-
"src": "https://cdn-icons-png.flaticon.com/512/4712/4712035.png",
|
| 668 |
-
"sizes": "192x192",
|
| 669 |
-
"type": "image/png"
|
| 670 |
-
},
|
| 671 |
-
{
|
| 672 |
-
"src": "https://cdn-icons-png.flaticon.com/512/4712/4712035.png",
|
| 673 |
-
"sizes": "512x512",
|
| 674 |
-
"type": "image/png"
|
| 675 |
-
}
|
| 676 |
-
]
|
| 677 |
-
}
|
| 678 |
-
return Response(json.dumps(data), mimetype='application/json')
|
| 679 |
-
|
| 680 |
-
if __name__ == '__main__':
|
| 681 |
-
app.run(host='0.0.0.0', port=7860)
|
| 682 |
-
""" # --- CRITICAL CLOSING QUOTE FOR HTML_TEMPLATE ---
|
| 683 |
|
| 684 |
# --- BACKEND ROUTES ---
|
| 685 |
@app.route("/", methods=["GET"])
|
|
|
|
| 108 |
|
| 109 |
return "⚠️ System Busy. Please try again."
|
| 110 |
|
| 111 |
+
# --- UI TEMPLATE (Fixed Quotes & Logic) ---
|
| 112 |
HTML_TEMPLATE = """
|
| 113 |
<!DOCTYPE html>
|
| 114 |
<html lang="en">
|
|
|
|
| 306 |
<div id="login-overlay">
|
| 307 |
<div class="login-box">
|
| 308 |
<h1 class="app-title" style="margin-bottom:10px;">Student's AI</h1>
|
| 309 |
+
<input type="text" id="username-input" placeholder="Your Name" style="width:100%; padding:15px; border-radius:12px; border:1px solid #333; background:#111; color:#fff; text-align:center; outline:none; margin-bottom:20px; font-size: 16px;" onkeydown="if(event.key==='Enter') handleLogin()">
|
| 310 |
<button onclick="handleLogin()" style="width:100%; padding:15px; border-radius:12px; border:none; background:#fff; font-weight:800; cursor:pointer; font-size: 16px;">Start Learning</button>
|
| 311 |
</div>
|
| 312 |
</div>
|
|
|
|
| 387 |
if(name) {
|
| 388 |
try { localStorage.setItem("student_ai_user", name); } catch(e){}
|
| 389 |
currentUser = name;
|
| 390 |
+
// FORCE HIDE DIRECTLY
|
| 391 |
+
const overlay = document.getElementById("login-overlay");
|
| 392 |
+
overlay.classList.add('hidden');
|
| 393 |
+
setTimeout(() => overlay.style.display = 'none', 500);
|
| 394 |
showApp();
|
| 395 |
} else {
|
| 396 |
input.style.border = "1px solid red";
|
| 397 |
setTimeout(() => input.style.border = "1px solid #333", 2000);
|
| 398 |
}
|
| 399 |
}
|
|
|
|
| 400 |
function handleLogout() {
|
| 401 |
try { localStorage.removeItem("student_ai_user"); } catch(e){}
|
| 402 |
const overlay = document.getElementById("login-overlay");
|
| 403 |
+
overlay.style.display = 'flex';
|
| 404 |
+
setTimeout(() => overlay.classList.remove('hidden'), 10);
|
| 405 |
document.getElementById('sidebar').classList.remove('open');
|
| 406 |
setTimeout(() => {
|
| 407 |
document.getElementById('chat-box').innerHTML = "";
|
|
|
|
| 655 |
box.scrollTop = box.scrollHeight;
|
| 656 |
}
|
| 657 |
|
| 658 |
+
checkLogin();
|
| 659 |
+
</script>
|
| 660 |
+
</body>
|
| 661 |
+
</html>
|
| 662 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 663 |
|
| 664 |
# --- BACKEND ROUTES ---
|
| 665 |
@app.route("/", methods=["GET"])
|