一、前端页面中
html文件中:
{% extends 'base.html' %}
{% block scripts %}
{{ super() }}
{# #}
{% endblock %}
{% block content %}
{{ super() }}
jQuery Example
+
=
?
点击开始计算
{% endblock %}
flask路由函数中
@check_info.route('/_add_numbers')
def add_numbers():
a = request.args.get('a', 0, type=int)
b = request.args.get('b', 0, type=int)
tt=jsonify(result=a + b)
return tt
@check_info.route('/weather',methods=['POST','GET'])
def weather():
list = [1, 2, 3, 4, 5, 6]
# return jsonify(month=[x for x in list])
return render_template('jso.html')
二、直接从flask路由函数中获取json数据然后渲染在前端页面中
{% extends 'base.html' %}
{% block scripts %}
{{ super() }}
{# #}
{% endblock %}
{% block content %}
{{ super() }}
{{ st }}
{% endblock %}
@check_info.route('/weather',methods=['POST','GET'])
def weather():
list = [1, 2, 3, 4, 5, 6]
return jsonify(month=[x for x in list])
@check_info.route('/ch')
def ch():
return render_template('charts.html')