
コード
6
章のコード
with open('todos.txt') as
tasks:
for chore in tasks:
print(chore, end='')
tasks = open('todos.txt')
for chore in tasks:
print(chore, end='')
tasks.close()
280
6
章
...
def log_request(req: 'flask_request', res: str) -> None:
with open('vsearch.log', 'a') as log:
print(req.form, req.remote_addr, req.user_agent, res, file=log, sep='|')
...
@app.route('/viewlog')
def view_the_log() -> str:
contents = []
with open('vsearch.log') as log:
for line in log:
contents.append([])
for item in line.split('|'):
contents[-1].append(escape(item))
titles = ('
フォームデータ
', '
リモートアドレス
', '
ユーザエージェント
', '
結果
')
return render_template('viewlog.html',
the_title='
ログの閲覧