From 19fc81c7fb12012faadaabbec45186278b1afd8b Mon Sep 17 00:00:00 2001 From: ralphi3 Date: Thu, 18 Jun 2026 10:36:26 +1200 Subject: [PATCH] Update app.py --- app.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/app.py b/app.py index 7b31903..2fcd500 100644 --- a/app.py +++ b/app.py @@ -23,18 +23,15 @@ with app.app_context(): def handle_submission(): form_username = request.form.get('username') form_email = request.form.get('email') - form_password = request.form.get('password') # 1. Grab password from HTML + form_password = request.form.get('password') - # Check for duplicates if User.query.filter_by(username=form_username).first(): return "

Username taken!

", 400 if User.query.filter_by(email=form_email).first(): return "

Email already registered!

", 400 - # 2. Hash the password into a secure scramble hashed_password = generate_password_hash(form_password) - # 3. Save the user with the scrambled hash new_user = User(username=form_username, email=form_email, password_hash=hashed_password) db.session.add(new_user) db.session.commit() @@ -47,10 +44,8 @@ def success(): @app.route('/users') def view_users(): - # Fetch all user records from the database all_users = User.query.all() - # Create a simple HTML table to display them nicely html_output = "

Registered Accounts

" html_output += "" @@ -59,7 +54,6 @@ def view_users(): html_output += "
IDUsernameEmail
" - # If the database is completely empty if not all_users: return "

No accounts found in the database yet.

"