Python - SQL - SQLite - List Comprehensions: Database Integrations - adjusting
Head First Python: A Learner’s Guide to the Fundamentals of Python Programming, A Brain-Friendly Guide、 Paul Barry(著)、 O’Reilly Mediaの Chapter 13.(List Comprehensions: Database Integrations)、SHARPEN YOUR PENCIL(606/682)の解答を求めてみる。
変更の必要がありそうなところをコメントアウトしてみた。
コード
webapp/app.py
# import os
from flask import Flask, render_template, request, session
# import swimclub
app = Flask(__name__)
app.secret_key = 'You will never guess...'
@app.get('/')
def index():
return render_template(
'index.html.j2',
title='Welcome to the Swimclub system',
)
# def populate_data():
# if 'swimmers' not in session:
# session['swimmers'] = {}
# filenames = os.listdir(swimclub.FOLDER)
# filenames.remove('.DS_Store')
# for filename in filenames:
# name, *_ = swimclub.read_swim_data(filename)
# if name not in session['swimmers']:
# session['swimmers'][name] = []
# session['swimmers'][name].append(filename)
@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'],
)
@app.post('/showfiles')
def display_swimmers_files():
name = request.form['swimmer']
# populate_data()
print(session['swimmers'])
return render_template(
'select.html.j2',
title='Select an event',
url='/showbarchart',
select_id='file',
# data=session['swimmers'][name],
)
@app.post('/showbarchart')
def show_bar_chart():
file_id = request.form['file']
# location = swimclub.produce_bar_chart(file_id, 'templates/')
# return render_template(location.split('/')[-1])
return ''
if __name__ == '__main__':
app.run(debug=True)