Spaces:
Running
Running
David Ko
commited on
Commit
ยท
a8dbc72
1
Parent(s):
a2e8511
Fix login functionality and translate UI to English
Browse files
api.py
CHANGED
@@ -1096,14 +1096,14 @@ LOGIN_TEMPLATE = '''
|
|
1096 |
<h1>Vision LLM Agent</h1>
|
1097 |
<form action="/login" method="post">
|
1098 |
<div class="form-group">
|
1099 |
-
<label for="username"
|
1100 |
<input type="text" id="username" name="username" required>
|
1101 |
</div>
|
1102 |
<div class="form-group">
|
1103 |
-
<label for="password"
|
1104 |
<input type="password" id="password" name="password" required>
|
1105 |
</div>
|
1106 |
-
<button type="submit"
|
1107 |
{% if error %}
|
1108 |
<p class="error-message">{{ error }}</p>
|
1109 |
{% endif %}
|
@@ -1120,12 +1120,17 @@ def login():
|
|
1120 |
username = request.form.get('username')
|
1121 |
password = request.form.get('password')
|
1122 |
|
|
|
|
|
1123 |
if username in users and users[username].password == password:
|
1124 |
login_user(users[username])
|
1125 |
next_page = request.args.get('next')
|
1126 |
-
|
|
|
|
|
1127 |
else:
|
1128 |
-
error = '
|
|
|
1129 |
|
1130 |
return render_template_string(LOGIN_TEMPLATE, error=error)
|
1131 |
|
|
|
1096 |
<h1>Vision LLM Agent</h1>
|
1097 |
<form action="/login" method="post">
|
1098 |
<div class="form-group">
|
1099 |
+
<label for="username">Username</label>
|
1100 |
<input type="text" id="username" name="username" required>
|
1101 |
</div>
|
1102 |
<div class="form-group">
|
1103 |
+
<label for="password">Password</label>
|
1104 |
<input type="password" id="password" name="password" required>
|
1105 |
</div>
|
1106 |
+
<button type="submit">Login</button>
|
1107 |
{% if error %}
|
1108 |
<p class="error-message">{{ error }}</p>
|
1109 |
{% endif %}
|
|
|
1120 |
username = request.form.get('username')
|
1121 |
password = request.form.get('password')
|
1122 |
|
1123 |
+
print(f"Login attempt: username={username}")
|
1124 |
+
|
1125 |
if username in users and users[username].password == password:
|
1126 |
login_user(users[username])
|
1127 |
next_page = request.args.get('next')
|
1128 |
+
if next_page:
|
1129 |
+
return redirect(next_page)
|
1130 |
+
return redirect('/')
|
1131 |
else:
|
1132 |
+
error = 'Invalid username or password'
|
1133 |
+
print(f"Login failed: {error}")
|
1134 |
|
1135 |
return render_template_string(LOGIN_TEMPLATE, error=error)
|
1136 |
|