So trying to finish a lab using Flask Templates
Here is my python code:
cryptosnapshots = (requests.get(f"https://api.finage.co.uk/snapshot/crypto?quotes=false&trades=true&symbols=&apikey=XXX")).json()
snapshot = (cryptosnapshots['lastTrades'][:20])
@app.route('/crypto_data', methods = ['GET']) # define the first route, the home route
def show_crypto(): # define the function that responds to the above route
if request.method == 'GET':
return render_template('show.html', snapshot = snapshot)
if __name__ == '__main__':
app.run()
and here is my the code from the html page:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
{% for snapshot in snapshots %}
<h2>Symbol: {{snapshot['s']}}</h2>
<p> Last Price: {{snapshot['p']}}<p>
{% endfor %}
</body>
</html>
When python returns the url and I add my "/crypto_data" endpoint, the page just shows up blank...is my error on the python side or the html side (or is it the api??)?
TIA!
Im expecting the url and endpoint to lead to an html list of all the last trading price from the first 20 cryptos on the list.
My first issue was breaking down the API json and I thought once that was solved it would be a breeze...
labs due Sunday, someone help lol