传递多个参数时使用context={}字典形式
info.py
1 from datetime import datetime 2 3 @app.route('/info/') 4 def person(): 5 class MyPerson(object): 6 Email = 'jpal124@gmail.com' 7 Time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') 8 dell=MyPerson() 9 context={'username':'Jack','age':39,'pdell':dell} 10 return render_template('info.html',**context)
info.html
1 <!doctype html> 2 <title>Flaskr</title> 3 <link rel=stylesheet type=text/css href="{{ url_for('static', filename='style.css') }}"> 4 <body> 5 <div class=page> 6 <p>用户名:</p>{{ username }} 7 <p>年龄:</p>{{ age }} 8 <p>邮箱:</p>{{ pdell.Email }} 9 <p>申请时间:</p>{{ pdell.Time }} 10 </div> 11 </body>