I'm currently trying to make a site that has some info that updates every once in a while with flask. When I run my python script, the CSS and HTML work perfectly. However, if I try to return a variable to my HTML and attempt to use it there, the text is just blank. My flask file and project layout seem to be mostly the same as a previous project, so I don't really know what's going on. Some help would be greatly appreciated!
Python-
import flask
from flask import Flask, render_template
import bs4
import requests
import json
app = Flask(__name__)
url = 'https://covidtracking.com/api/v1/states/PA/current.json'
payload = {}
headers = {}
response = requests.request("GET", url, headers=headers, data=payload)
penndata = response.json()
positivecases = penndata['positive']
# negativecases = penndata['negative']
hospitalized = penndata['hospitalizedCurrently']
ventilator = penndata['onVentilatorCurrently']
deaths = penndata['death']
print(penndata)
@app.route("/")
def home():
return render_template("template.html", posititivecases=positivecases, hospitalized=hospitalized, ventilator=ventilator, deaths=deaths)
if __name__ == '__main__':
app.run(host='0.0.0.0')
part of the HTML-
<div class="flex-container">
<div class="flex-child">
Cases
<p class="casesp">{{positivecases}}</p>
</div>
<div class="flex-child">
Deaths
<p class="deathsp">9999</p>
</div>
<div class="flex-child">
Hospitalized
<p class="hospitalizedp">9999</p>
</div>
<div class="flex-child">
On ventilator
<p class="ventilatorp">999</p>
</div>
</div>