Skip to content

Instantly share code, notes, and snippets.

/application.py Secret

Created February 21, 2017 17:48
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save anonymous/39c73c5f19c04210cd57fba9234ffa0c to your computer and use it in GitHub Desktop.
application.py - shared from CS50 IDE
# query database for username
rows = db.execute("SELECT * FROM users WHERE username = :username", username=request.form.get("username"))
# ensure password is correct
if len(rows) != 1 or not pwd_context.verify(request.form.get("password"), rows[0]["hash"]):
return apology("invalid username and/or password")
db.execute("INSERT INTO users (username, password) VALUES(:name, :password)", name=request.form["username"], \
password=request.form["hash"])
# remember which user has logged in
session["user_id"] = rows[0]["id"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment