标签:pyhton
hello.py
from flask import Flask,render_template
# -*- coding:utf-8 -*-
app = Flask(__name__)
@app.route(‘/‘,methods=["GET"])
def hello_world():
wangmin = ‘wangming‘
nav_list = [u‘首页‘,u‘娱乐‘,u‘新闻‘]
my_dict = {‘titile‘:‘mybook‘,‘content‘:‘asalsjaksjalksjalksjals‘}
return render_template(‘index.html‘,wangmin = wangmin,nav_list =nav_list,my_dict = my_dict)
if __name__ == ‘__main__‘:
app.run(‘0.0.0.0‘,5001,debug=True)
templates/index.html
<h4>welcome to {{wangmin}}templates</h4>
{% for nav in nav_list %}
<li><ahref=‘‘>{{nav}}</a></li>
{% endfor %}
{% for key,value in my_dict.items() %}
{{key}}:{{value}}
<br/>
{% endfor %}
在前端遍历返回的列表和字典
本文出自 “dba天空” 博客,请务必保留此出处http://9425473.blog.51cto.com/9415473/1712124
标签:pyhton
原文地址:http://9425473.blog.51cto.com/9415473/1712124