Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -63,6 +63,8 @@ def signup():
|
|
| 63 |
@app.route('/login', methods=['GET', 'POST'])
|
| 64 |
def login():
|
| 65 |
if request.method == 'POST':
|
|
|
|
|
|
|
| 66 |
username = request.form.get('username', '').strip()
|
| 67 |
conn = get_db_connection()
|
| 68 |
cursor = conn.cursor()
|
|
@@ -73,12 +75,12 @@ def login():
|
|
| 73 |
if user:
|
| 74 |
session.permanent = True
|
| 75 |
session['user'] = username
|
| 76 |
-
print(f"DEBUG: User {username} logged in successfully!")
|
| 77 |
return redirect(url_for('dashboard'))
|
| 78 |
else:
|
| 79 |
-
flash("User not found!
|
| 80 |
return render_template('login.html')
|
| 81 |
|
|
|
|
| 82 |
@app.route('/dashboard')
|
| 83 |
def dashboard():
|
| 84 |
if 'user' in session:
|
|
@@ -109,10 +111,17 @@ def process_frame():
|
|
| 109 |
except Exception as e:
|
| 110 |
return jsonify({"error": "Processing error"}), 400
|
| 111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
@app.route('/logout')
|
| 113 |
def logout():
|
| 114 |
-
session.clear()
|
| 115 |
-
|
|
|
|
|
|
|
|
|
|
| 116 |
|
| 117 |
if __name__ == '__main__':
|
| 118 |
app.run(host='0.0.0.0', port=7860)
|
|
|
|
| 63 |
@app.route('/login', methods=['GET', 'POST'])
|
| 64 |
def login():
|
| 65 |
if request.method == 'POST':
|
| 66 |
+
# Login ke waqt session clear karein taake auto-logout na ho
|
| 67 |
+
session.clear()
|
| 68 |
username = request.form.get('username', '').strip()
|
| 69 |
conn = get_db_connection()
|
| 70 |
cursor = conn.cursor()
|
|
|
|
| 75 |
if user:
|
| 76 |
session.permanent = True
|
| 77 |
session['user'] = username
|
|
|
|
| 78 |
return redirect(url_for('dashboard'))
|
| 79 |
else:
|
| 80 |
+
flash("User not found!", "error")
|
| 81 |
return render_template('login.html')
|
| 82 |
|
| 83 |
+
|
| 84 |
@app.route('/dashboard')
|
| 85 |
def dashboard():
|
| 86 |
if 'user' in session:
|
|
|
|
| 111 |
except Exception as e:
|
| 112 |
return jsonify({"error": "Processing error"}), 400
|
| 113 |
|
| 114 |
+
# @app.route('/logout')
|
| 115 |
+
# def logout():
|
| 116 |
+
# session.clear()
|
| 117 |
+
# return redirect(url_for('login'))
|
| 118 |
@app.route('/logout')
|
| 119 |
def logout():
|
| 120 |
+
session.clear() # Clear everything
|
| 121 |
+
# Browser ko cache saaf karne ka kahein
|
| 122 |
+
response = redirect(url_for('login'))
|
| 123 |
+
response.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate'
|
| 124 |
+
return response
|
| 125 |
|
| 126 |
if __name__ == '__main__':
|
| 127 |
app.run(host='0.0.0.0', port=7860)
|