4

Check50 showed me expected to find "28.00" in page, but it wasn't found. I don't know where is my mistake. Can anyone help me out? Any help will be greatly appreciated.

Here is my quote():

    @app.route("/quote", methods=["GET", "POST"])
    @login_required
    def quote():
        """Get stock quote."""

        # User reached route via POST (as by submitting a form via POST)
        if request.method == "POST":
            stock = lookup(request.form.get("symbol"))

            # Ensure symbol was valid
            if not stock:
                return apology("Invalid symbol!", 400)

            return render_template("quoted.html", name=stock["name"], symbol=stock["symbol"], price=stock["price"])

        else:
            return render_template("quote.html")

Here is my quote.html:

{% extends "layout.html" %}

{% block title %}
    Quote
{% endblock %}

{% block main %}
    <form action="/quote" method="post">
        <div class="form-group">
            <input autocomplete="off" autofocus class="form-control" name="symbol" placeholder="Symbol" type="text"/>
        </div>
        <button class="btn btn-primary" type="submit">Quote</button>
    </form>
{% endblock %}

Here is my quoted.html:

{% extends "layout.html" %}

{% block title %}
    Quoted
{% endblock %}

{% block main %}
    <form action="/quote" method="post">
        A share of {{ name }} ({{ symbol }}) costs ${{ price }}.
    </form>
{% endblock %}

1 Answer 1

22

I found a solution here. I didn't format the price of stock by usd(). When I changed my code from {{ price }} to {{ price | usd }} in quoted.html, it worked.

2
  • Thanks Helpfull Commented Sep 25, 2021 at 8:48
  • Thanks! Now arose the problem with 'AAAA'...
    – Greg
    Commented Dec 20, 2023 at 23:21

You must log in to answer this question.

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