Spaces:
Running
Running
Update app.py
Browse files32 unmodified lines333435363637383839404140414243464445464732 unmodified lines
# Check if the username already exists if User.query.filter_by(username=username).first(): return "Username already exists. Please choose another." return "Username already exists. Please choose another.", 400
# Hash the password # Hash the password and save the user to the database hashed_password = generate_password_hash(password)
# Save the user to the database new_user = User(username=username, password=hashed_password) db.session.add(new_user) db.session.commit()
return "User registered successfully!" return "User registered successfully!", 201
# User login route@app.route('/login', methods=['POST'])app.py+3-5