from flask import render_template, jsonify
import requests
from app.test_blueprint import app
@app.route('/')
def index():
url = 'http://api.address'
response = requests.get(url)
data = response.json()
return render_template('index.html', data=data)
if __name__ == '__main__':
app.run()
我似乎无法访问从json响应创建的字典中的键内的项目
<ul>
{% for key in data %}
<li>{{data[key].items}}</li>
{% endfor %}
</ul>
答案 0 :(得分:0)
我认为它应该是这样的:
<ul>
{% for vlaue in data.values() %}
<li>{{value}}</li>
{% endfor %}
</ul>