Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @app.route("/register", methods=["GET", "POST"])
- def register():
- """Register user"""
- # User reached route via POST (as by submitting a form via POST)
- if request.method == "POST":
- # Stored POST data to variables
- username = request.form.get('username')
- password = request.form.get('password')
- confirmation = request.form.get('confirmation')
- # Ensure username was submitted
- if not username:
- return apology("must provide username", 403)
- # Ensure password and confirmation were both submitted
- elif not password:
- return apology("must provide password in both fields", 403)
- # Ensure passwords match
- elif confirmation != password:
- return apology("passwords do not match", 403)
- elif db.execute('SELECT id FROM users WHERE username = ?',
- (username,)).fetchone() is not None:
- return apology("Username already exists", 403)
- elif db.execute('SELECT id FROM users WHERE username = ?',
- (username,)).fetchone() is not None:
- TypeError: execute() takes 2 positional arguments but 3 were given
- from cs50 import SQL; and
- db = SQL("sqlite:///finance.db")
- import sqlite3; and
- db = sqlite3.connect('finance.db')
- elif db.execute('SELECT id FROM users WHERE username = ?',
- (username,)).fetchone() is not None:
- return apology("Username already exists", 403)
Add Comment
Please, Sign In to add comment