0

@app.route("/quote", methods=["GET", "POST"]) @login_required def quote(): if request =="POST": rows = lookup(request.form.get("quote"))

    if not rows:
        return apology("Invalid Symbol")

    return render_template("quote.html", stock=rows)
else:
    return render_template("quote.html")

return render_template("quote.html")

@app.route("/register", methods=["GET","POST"]) def register(): if request.method == "POST":

    if request.form.get("username")=='null':
        return render_template("Provide a username")

    elif request.form.get("password")=='null':
        return render_template("Provide a password")

    elif request.form.get("confirmation")=='null':
        return render_template("checking for password")

    elif request.form.get("password") != request.form.get("confirmation"):
        return apology("password and confirmation don't match!")

    result = db.execute("INSERT INTO users (username, hash) \
                         VALUES(:username, :hash)", \
                         username=request.form.get("username"), \
    hash=pwd_context.encrypt(request.form.get("password")))

    if not result:
        return apology("Username already exists! Please try another one")

    rows = db.execute("SELECT * from users WHERE username = :username", username = request.form.get("username"))
    session["user_id"] = rows[0]["id"]
    return redirect(url_for("index"))
else:
    return render_template("register.html")
2
  • Please clarify what apology you are expecting and what system does instead. – DinoCoderSaurus Jun 25 '17 at 20:15
  • quote.html is not taking the value and it redirects to the same page instead of showing some data from the lookup folder .It is unable find the symbol and display information about the share. Please provide me with some logic. Quote.html is not returning the apology when no data is provided to it "Invalid Symbol ". – Nadeem dada Jun 26 '17 at 10:52
0

Looks like a problem here if request =="POST":. request is never equal POST. Review the login function (or your own register function) to realize the correct object to test.

2
  • and one more thing, method get and method post should render different html template. @DinoCodeSaurus, one question though, not sure 'if not rows' and 'if rows == None' the same thing? – Michael Zhang Jun 26 '17 at 12:46
  • @MichaelZhang: Yes, "None" is "Falsey". Python Truth Value Testing – DinoCoderSaurus Jun 26 '17 at 12:55

You must log in to answer this question.

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