Advertisement
Guest User

Untitled

a guest
Aug 28th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. # Signup route example, hashing with "sha256" method to fix the user signup and login system at PythonAnyWhere
  2.  
  3. @app.route("/signup", methods=["GET", "POST"])
  4. def signup():
  5. form = RegisterForm()
  6.  
  7. if form.validate_on_submit():
  8. hashed_pw = generate_password_hash(form.password.data, method="sha256")
  9. new_user = Users(username=form.username.data, email=form.email.data, password=hashed_pw)
  10. db.session.add(new_user)
  11. db.session.commit()
  12. flash("You've been registered successfully", "alert-success")
  13. return redirect(url_for("signin"))
  14.  
  15. return render_template("signup.html", form=form)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement