问题描述
这是检查代码输入正确的代码,然后在引用的模板上显示名称、价格和代码。
@app.route("/quote",methods=["GET","POST"])
@login_required
def quote():
"""Get stock quote."""
if request.method == "POST":
# Ensure ticker was submitted
if not request.form.get("symbol"):
return apology("must input stock symbol")
# Get symbol and make sure it exists
quote = lookup(request.form.get("symbol"))
if not quote:
return apology("symbol does not exist")
# to show company name,price,symbol
else:
return render_template("quoted.html",quote=quote)
# User reached route via GET (as by clicking a link or via redirect)
else:
return render_template("quote.html")
解决方法
IEX 更改了 API。您可以在 helpers.py 的 this reddit post
中找到查找功能的新代码 ,不,lookup() 在 helpers.py 中是正确的。我可以从 CS50 的答案中得到一个报价。有什么方法可以检查我的令牌是否正确?我可以登录我的财务应用,但无法获取报价。