for loop / jinja2
+34 · 2 files changed
-
flask-blog.py+7 −0 -
templates/weather-average.html+27 −0
@@ -11,6 +11,13 @@ def hello_world(): def user(name): return render_template('user.html',name=name) +@app.route('/jin2/loop') +def index(): + months = ['January','February','March','April','May','June','July', + 'August','September','October','November','December'] + + return render_template('weather-average.html',city='Portland, OR', + months=months) if __name__ == '__main__': app.run(debug=True) @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<html> +<head lang="en"> + <meta charset="UTF-8"> + <title></title> +</head> +<body> + <h2>{{ city }}</h2> + <hr> + <table> + <tr> + <th>Month</th> + <th>Min</th> + <th>Max</th> + <th>Rainfall</th> + </tr> + {% for month in months %} + <tr> + <td>{{ month }}</td> + <td></td> + <td></td> + <td></td> + </tr> + {% endfor %} + </table> +</body> +</html> \ No newline at end of file