計算機科学のブログ

ほしい物リスト

Python - Building a Webapp: Web Development - Flask, HTML, Jinja, render_template

Head First Python: A Learner’s Guide to the Fundamentals of Python Programming, A Brain-Friendly GuidePaul Barry(著)、 O’Reilly Mediaの Chapter 7.(Building a Webapp: Web Development)、EXERCISE(368/682)の解答を求めてみる。

コード

webapp/app.py

@app.get('/swimmers')
def display_swimmers():
    populate_data()
    return render_template(
        'select.html.j2',
        title='Select a swimmer',
        url='showfiles',
        select_id='swimmer',
        data=session['swimmers'],
    )