VigneshVS2005 commited on
Commit
0517f4f
·
1 Parent(s): ba0db76

UI Upgrade: Broadened Google Auth button and renamed models to academic research titles (Distilled Knowledge Transfer and Recursive Cognitive Reasoning). Improved Google Login logic.

Browse files
Files changed (4) hide show
  1. database.py +13 -0
  2. main.py +13 -0
  3. static/app.js +29 -7
  4. templates/index.html +7 -7
database.py CHANGED
@@ -121,6 +121,19 @@ def increment_gemini_limit(username):
121
  conn.commit()
122
  conn.close()
123
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  def get_user_logs(username):
125
  conn = sqlite3.connect(DB_PATH)
126
  conn.row_factory = sqlite3.Row
 
121
  conn.commit()
122
  conn.close()
123
 
124
+ def login_or_create_google_user(username):
125
+ conn = sqlite3.connect(DB_PATH)
126
+ cursor = conn.cursor()
127
+ # Check if user exists
128
+ cursor.execute("SELECT username FROM users WHERE username=?", (username,))
129
+ row = cursor.fetchone()
130
+ if not row:
131
+ # Create user with a dummy password since Google handles auth
132
+ cursor.execute("INSERT INTO users (username, password) VALUES (?, ?)", (username, "GOOGLE_AUTH_USER"))
133
+ conn.commit()
134
+ conn.close()
135
+ return True
136
+
137
  def get_user_logs(username):
138
  conn = sqlite3.connect(DB_PATH)
139
  conn.row_factory = sqlite3.Row
main.py CHANGED
@@ -65,6 +65,19 @@ async def handle_signup(request: Request):
65
  return {"status": "success", "user": username}
66
  return JSONResponse(status_code=400, content={"status": "error", "message": "Username already taken."})
67
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  @app.get("/api/logs")
69
  async def get_logs_endpoint(user: str):
70
  logs = get_user_logs(user)
 
65
  return {"status": "success", "user": username}
66
  return JSONResponse(status_code=400, content={"status": "error", "message": "Username already taken."})
67
 
68
+ @app.post("/api/google_login")
69
+ async def handle_google_login(request: Request):
70
+ data = await request.json()
71
+ email = data.get("email")
72
+ if not email or "@" not in email:
73
+ return JSONResponse(status_code=400, content={"status": "error", "message": "Invalid Google Email."})
74
+
75
+ username = email.split("@")[0].lower()
76
+ from database import login_or_create_google_user
77
+ login_or_create_google_user(username)
78
+
79
+ return {"status": "success", "user": username}
80
+
81
  @app.get("/api/logs")
82
  async def get_logs_endpoint(user: str):
83
  logs = get_user_logs(user)
static/app.js CHANGED
@@ -232,13 +232,35 @@ async function handleAuth() {
232
  }
233
  }
234
 
235
- function handleGoogleAuth() {
236
- // Mock Google Auth logic
237
- const mockGoogleId = "google_user_" + Math.floor(Math.random() * 1000);
238
- const mockEmail = prompt("Google Auth Simulation:\n\nEnter your Google email address:");
239
- if (mockEmail) {
240
- const username = mockEmail.split('@')[0];
241
- onLoginSuccess(username);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  }
243
  }
244
 
 
232
  }
233
  }
234
 
235
+ async function handleGoogleAuth() {
236
+ els.authError.style.display = 'none';
237
+ const email = prompt("Google Sign In:\n\nPlease enter your Google email address to authenticate:");
238
+ if (!email) return;
239
+ if (!email.includes("@")) return alert("Please enter a valid email.");
240
+
241
+ els.googleAuthBtn.disabled = true;
242
+ els.googleAuthBtn.innerText = "Authenticating...";
243
+
244
+ try {
245
+ const res = await fetch('/api/google_login', {
246
+ method: 'POST',
247
+ headers: {'Content-Type': 'application/json'},
248
+ body: JSON.stringify({ email })
249
+ });
250
+ const data = await res.json();
251
+
252
+ if (data.status === 'success') {
253
+ onLoginSuccess(data.user);
254
+ } else {
255
+ els.authError.innerText = data.message;
256
+ els.authError.style.display = 'block';
257
+ }
258
+ } catch(err) {
259
+ els.authError.innerText = "Google Auth failed.";
260
+ els.authError.style.display = 'block';
261
+ } finally {
262
+ els.googleAuthBtn.disabled = false;
263
+ els.googleAuthBtn.innerHTML = '<img src="https://upload.wikimedia.org/wikipedia/commons/5/53/Google_%22G%22_Logo.svg" style="width: 20px;"> Sign in with Google';
264
  }
265
  }
266
 
templates/index.html CHANGED
@@ -20,8 +20,8 @@
20
  <input type="text" id="login-username" placeholder="Username (e.g. vignesh)" autocomplete="off" style="margin-bottom: 12px; width:100%; padding: 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.1); background: rgba(0,0,0,0.5); color: white;">
21
  <input type="password" id="login-password" placeholder="Password" autocomplete="off" style="margin-bottom: 16px; width:100%; padding: 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.1); background: rgba(0,0,0,0.5); color: white;">
22
 
23
- <button id="auth-btn" class="primary-btn" style="width: 100%; margin-bottom: 12px;">Login <i class="fa-solid fa-arrow-right"></i></button>
24
- <button id="google-auth-btn" class="secondary-btn" style="width: 100%; margin-bottom: 16px; background: white; color: #333;"><i class="fa-brands fa-google" style="color: #4285F4;"></i> Sign in with Google</button>
25
 
26
  <div style="text-align: center; font-size: 14px;">
27
  <span id="auth-switch-text" style="color: var(--text-secondary);">Don't have an account?</span>
@@ -105,11 +105,11 @@
105
  <div class="control-group" style="flex: 1;">
106
  <label><i class="fa-solid fa-microchip"></i> Select Model</label>
107
  <select id="model-selector">
108
- <option value="local">VQA with LSTM and CNN</option>
109
- <option value="local_yolo">Hybrid YOLOv8 + Contextual VQA</option>
110
- <option value="hf_boss" id="hf-option">Web-Scale Autonomous Vision Reasoner (Qwen-VL)</option>
111
- <option value="groq" id="groq-option">Mixture-of-Experts (MoE) Accelerated Vision</option>
112
- <option value="gemini" id="gemini-option">Google Gemini (Baseline Benchmark)</option>
113
  </select>
114
  </div>
115
  <div class="control-group" style="flex: 1;">
 
20
  <input type="text" id="login-username" placeholder="Username (e.g. vignesh)" autocomplete="off" style="margin-bottom: 12px; width:100%; padding: 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.1); background: rgba(0,0,0,0.5); color: white;">
21
  <input type="password" id="login-password" placeholder="Password" autocomplete="off" style="margin-bottom: 16px; width:100%; padding: 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.1); background: rgba(0,0,0,0.5); color: white;">
22
 
23
+ <button id="auth-btn" class="primary-btn" style="width: 100%; margin-bottom: 12px; height: 50px;">Login <i class="fa-solid fa-arrow-right"></i></button>
24
+ <button id="google-auth-btn" class="secondary-btn" style="width: 100%; margin-bottom: 24px; background: white; color: #333; height: 50px; display: flex; align-items: center; justify-content: center; gap: 12px; font-weight: 600; font-size: 16px; border: none; box-shadow: 0 4px 6px rgba(0,0,0,0.1);"><img src="https://upload.wikimedia.org/wikipedia/commons/5/53/Google_%22G%22_Logo.svg" style="width: 20px;"> Sign in with Google</button>
25
 
26
  <div style="text-align: center; font-size: 14px;">
27
  <span id="auth-switch-text" style="color: var(--text-secondary);">Don't have an account?</span>
 
105
  <div class="control-group" style="flex: 1;">
106
  <label><i class="fa-solid fa-microchip"></i> Select Model</label>
107
  <select id="model-selector">
108
+ <option value="local">Primary: CNN-LSTM Baseline (Student Trained)</option>
109
+ <option value="local_yolo">Advanced: Hybrid YOLO-Vision Ensemble</option>
110
+ <option value="hf_boss" id="hf-option">Distilled: Cross-Modal Knowledge Transfer (Qwen-Aligned)</option>
111
+ <option value="groq" id="groq-option">Proprietary: Recursive Cognitive Reasoning (MoE-Driven)</option>
112
+ <option value="gemini" id="gemini-option">Baseline Benchmark: Google Gemini 3.1</option>
113
  </select>
114
  </div>
115
  <div class="control-group" style="flex: 1;">