I'm working on the register() method for Pset7. I've written a new html template register.html which seems to work - when I run Flask and click on the register link, I get my newly-created register page (yay!):
My register() method - so far - is below.
@app.route("/register", methods=["GET", "POST"]) def register(): """Register user.""" # forget any user_id session.clear() # if user reached route via POST (as by submitting a form via POST) if request.method == "POST": # ensure username was submitted if not request.form.get("username"): return apology("You must submit a username") # ensure password was submitted elif not request.form.get("password"): return apology("You must submit a password") # ensure password_confirmation was submitted elif not request.form.get("password_confirmation"): return apology("You must re-enter your password") # test to check the code gets to this point else: return apology("Well done Matt, you got here!") # else if user reached route via GET (as by clicking a link or via redirect) else: return render_template("register.html")
I now want to test that it's working, by entering in blank entries to the username, password, and password_confirmation fields in the html form.
When I do this, however, I don't get the apology "memes" I was expecting, as set out in my register() method. Instead, I get the memes with text as as defined in the login() method - see below. And the URL shown is: http://ide50-mattfriend.cs50.io/login [note the /login at the end]
Can anyone help explain what's going on? If needed I can post the rest of my code for application.py.
Thanks in advance for your help.