計算機科学のブログ

ほしい物リスト

Python - Flask - Building a Webapp: Web Development - form, request, post method

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(373/682)の解答を求めてみる。

コード webapp/app.py

@app.post('/showfiles')
def display_swimmer_files():
    populate_data()
    name = request.form['name']
    return render_template(
        'select.html.j2',
        title='Select an event',
        url='/showbarchart',
        select_id='file',
        data=session['swimmers'][name],
    )