< jinja template tutorial >
< Python Code >
1
2
3
4
5
6
7
8
9
10
|
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/result')
def result():
dict = {'phy':50,'che':60,'maths':70}
return render_template('result.html', result = dict)
if __name__ == '__main__':
app.run(host='0.0.0.0', port='80', debug = True)
|
< result.html >
1
2
3
4
5
6
7
8
9
10
11
12
13
|
<!doctype html>
<html>
<body>
<table border = 1>
{% for key, value in result.items() %}
<tr>
<th> {{ key }} </th>
<td> {{ value }} </td>
</tr>
{% endfor %}
</table>
</body>
</html>
|
물리(physics), 화학(chemistry), 수학(math) 점수 출력
'PRACTICE > Basic' 카테고리의 다른 글
[Flask] jinja template 활용하여 static 폴더의 자료 가져오기 (0) | 2020.09.24 |
---|---|
[Flask] request.form 사용하여 key, value 값 전달 (0) | 2020.09.23 |
[Flask] request 사용하여 POST, GET 출력 (0) | 2020.09.03 |
[Flask] url_for, redirect 사용하여 main, major, minor 페이지 출력 (0) | 2020.09.03 |
[Flask] int, float값 구분하여 웹 페이지 호출 (0) | 2020.09.03 |
댓글