File "/home/ubuntu/workspace/pset7/finance/application.py", line 267, in register session["user_id"] = result[0]["id"] TypeError: 'int' object is not subscriptable
if request.method == "POST":
if not (request.form.get("password") or request.form.get("confirmation") or request.form.get("username")):
return apology("please enter all details", 403)
if request.form.get("confirmation") != request.form.get("password"):
return apology("entered passwords don't match", 403)
result = db.execute("INSERT INTO users (username, hash) \ VALUES(:username, :hash)", \ username=request.form.get("username"), \ hash=generate_password_hash(request.form.get("password")))
if not result :
return apology("username already taken", 403)
#Remember which user has logged in
session["user_id"] = result[0]["id"]
return redirect("/index")
else:
return render_template("register.html")