Whenever I try to login or register after running "flask run" on pset7, I receive an internal server error. enter image description hereWhen I run check50, it says that registering a user does not succeed and registration does not reject a duplicate username because of some exception. enter image description here I have no idea what the errors mean or how to resolve them. This is my code for register: `session.clear()

# User reached route via POST
if request.method == "POST":

    # Ensure username was submitted
    if not request.form.get("username"):
        return apology("must provide username")

    # Ensure password was submitted
    elif not request.form.get("password"):
        return apology("must provide password")

    # password length
    elif len(request.form.get("password")) < 8:
        return apology("Password must contain at least 8 characters")

    # Ensure password and confirmation password are the same
    elif request.form.get("password") != request.form.get("confirmation"):
        return apology("The passwords don't match")

    password = request.form.get("password")
    hashed = generate_password_hash(password)

    # Create new user and store hashed password
    result = db.execute("INSERT INTO users (username, hash) VALUES(:username, :hash)", username = request.form.get("username"), hash = hashed)
    # Verify that username is unique
    if not result:
        return apology("This username already exists.")

    # Query database for username
    rows = db.execute("SELECT * FROM users WHERE username = :username",

    # Ensure username exists and password is correct
    if len(rows) != 1 or not check_password_hash(rows[0]["hash"], request.form.get("password")):
        return apology("invalid username and/or password", 403)

    # Remember which user has logged in
    session["user_id"] = rows[0]["id"]

    # Redirect user to home page
    return redirect("/")

# If user reached route via get
    return render_template("register.html")

` Is there even an error here, or could it be somewhere else? Additionally, while running flask I get this in my terminal windowenter image description here Please help ASAP!


An "internal server error" will always report detail in the flask terminal. In this case, your eye should be drawn to the text in yellow. The error is being thrown by the usd function. portfolio_value is a list. usd function takes a numeric type as the argument. It is reporting the problem in index, line 66.

You must log in to answer this question.

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