I am struggling with the finance API. I am calling the lookup function as I have seen many others code on these message boards but I keep receiving "none" as the return value from the function. I have tried it with quite a few live stock tickers with the same results. I have added some print statements so I know my form is receiving the ticker correctly and that look up is returning None.
My code is below as well as my terminal feedback. Does anything here jump off the screen at anyone as being flawed?
PS I am entering export API_KEY=(whatever the long string of letters/symbols) at the command line before I start. If I don't the website will not load.
Thanks, Rob
~/pset8/finance/ $ flask run
* Serving Flask app "application.py" (lazy loading)
* Environment: development
* Debug mode: off
* Running on https://10cb4773-2a36-4838-b05e-0451feb9f601-ide.cs50.xyz:8080/ (Press CTRL+C to quit)
* Restarting with stat
INFO:werkzeug:192.168.214.103 - - [09/Sep/2020 23:08:19] "GET /quote HTTP/1.0" 302 -
INFO:werkzeug:192.168.214.103 - - [09/Sep/2020 23:08:19] "GET /login HTTP/1.0" 200 -
INFO:werkzeug:192.168.214.103 - - [09/Sep/2020 23:08:19] "GET /static/styles.css HTTP/1.0" 200 -
DEBUG:cs50:SELECT * FROM users WHERE username = 'rob'
INFO:werkzeug:192.168.214.103 - - [09/Sep/2020 23:08:23] "POST /login HTTP/1.0" 302 -
DEBUG:cs50:SELECT * FROM holdings;
INFO:werkzeug:192.168.214.103 - - [09/Sep/2020 23:08:23] "GET / HTTP/1.0" 200 -
INFO:werkzeug:192.168.214.103 - - [09/Sep/2020 23:08:23] "GET /static/styles.css HTTP/1.0" 200 -
INFO:werkzeug:192.168.214.103 - - [09/Sep/2020 23:08:26] "GET /quote HTTP/1.0" 200 -
INFO:werkzeug:192.168.214.103 - - [09/Sep/2020 23:08:26] "GET /static/styles.css HTTP/1.0" 200 -
aapl
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): cloud-sse.iexapis.com:443
DEBUG:urllib3.connectionpool:https://cloud-sse.iexapis.com:443 "GET /stable/stock/aapl/quote?token=api HTTP/1.1" 403 None
None
INFO:werkzeug:192.168.214.103 - - [09/Sep/2020 23:08:31] "POST /quote HTTP/1.0" 200 -
INFO:werkzeug:192.168.214.103 - - [09/Sep/2020 23:08:31] "GET /static/styles.css HTTP/1.0" 200 -
def quote():
#create form to obtain quote from user
#see quote.html.
#determine if request.method=post
if request.method=="POST":
#query API for quote
quote=request.form.get("ticker")
print(quote)
quote=quote.lower()
info=lookup(quote)
print(info)
#determine if quote is valid
#if not valid return message to enter a valid quote
if not info:
flash("Quote not valid, please enter valid stock ticker")
return render_template("quote.html")
#else quote is valid and return price
else:
return render_template("quote.html", quote=info)
return render_template("quote.html")