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"])
@login_required
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)
else:
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"/>
</div>
<button class="btn btn-primary" type="submit">Quote</button>
</form>
{% 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!
helpers.py
? Yahoo shut down the old API, so oldlookup
would always returnNone
. – Blauelf Nov 21 '17 at 23:18