I am struggling with the implementation of register. I started small, just copied the content of the already defined login-function as well as the content of login.html. So, my first attempt is just to check if I can insert a new user and the password into the database wihtout the password-confirmation field and without password hashing. My code in application.py:
@app.route("/register", methods=["GET", "POST"]) def register(): """Register user""" if request.method == "POST": # Ensure username was submitted if not request.form.get("username"): return apology("must provide username", 403) # Ensure password was submitted elif not request.form.get("password"): return apology("must provide password", 403) # insert user into database db.execute("INSERT INTO finance (username, hash) VALUES (?, ?)", request.form.get("username"), request.form.get("password")) # Redirect user to login page return redirect("/login") # User reached route via GET (as by clicking a link or via redirect) else: return render_template("register.html")
My template looks like this and is stored in the templates directory:
Edited: Executing this I get a 500 code. The message in the terminal window is RuntimeError: no such table: finance How can that be? The db is implemented in the code and I checked that I don't have a spelling error.
Thanks in advance.