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!): enter image description here

My register() method - so far - is below.

@app.route("/register", methods=["GET", "POST"])
def register():
"""Register user."""

# forget any user_id

# 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
        return apology("Well done Matt, you got here!")

# else if user reached route via GET (as by clicking a link or via redirect)
    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]

enter image description here

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.


What is the form action attribute in register.html? Sounds like it's calling login instead of register.

| improve this answer | |
  • Doh! Thanks once more DinoCoderSaurus :) – Matt Friend May 18 '17 at 16:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .