計算機科学のブログ

ほしい物リスト

Python - Flask - Building a Webapp: Web Development - render_template, jinja2, for loop

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)、SHArPEN YOUR PENCIL(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=sorted(session['swimmers']),
    )


###