So, I'm struggling with pset7 a lot (mostly because I've never programmed before either =/) now I'm on quote and it's always rendering an apology after I fill in the form. I can't quite figure out what I'm doing wrong, perhaps it's the way I'm dealing with lookups return value? I dunno...

Heres my code for quote

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

    if request.method == "POST":
        search = lookup(request.form["symbol"])
        if search is None:
            return apology("Invalid symbol")
        return render_template("quoted.html", stock = search)
        return render_template("quote.html")

Here's my html for quote.html

{% extends "layout.html" %}

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

Here's my code for quoted.html

{% extends "layout.html" %}

{% block main %}
    A share of {{stock.name}} ({{stock.symbol}}) is ${{stock.price}}
{% endblock %}

Thank you all in advance!

  • Have you updated your helpers.py? Yahoo shut down the old API, so old lookup would always return None. – Blauelf Nov 21 '17 at 23:18
  • Have you fixed the problem? I'm getting a similar problem. – Satanic Saint Dec 1 '17 at 14:56
  • Yes I fixed it and forgot to post it here. Sorry! I just redownloaded helpers.py, apparently yahoo changed their stock plataform so lookup was always returning null Thanks Blauelf for the help! – Gabriel Luz Carpes Dec 2 '17 at 18:57

You must log in to answer this question.

Browse other questions tagged .