【发布时间】:2019-10-09 08:56:29
【问题描述】:
我在带有 python3.6 的烧瓶服务器中有一个字典,并希望使用烧瓶模板框架将 dict_test 字典移动为 Javascript 字典。哪条路?
flask-server.py
@app.route("/app", methods=['GET'])
def home():
dict_test = {"key1":10, "k2":'hello'}
return render_template("index.html", text_lists=dict_test)
logging.info("Listener started")
if __name__ == "__main__":
app.run(host='0.0.0.0', port=5000)
index.html
<body>
<script>
var tp_data = {{text_lists}};
</script>
....
</body>
【问题讨论】: