app/main.py: flash a message after deleting a word (use bootstrap alerts -- add additional content, e.g., a bolder congratulations).

Lanhui-flash-messages
Hui Lan 2021-08-02 19:17:54 +08:00
parent 08bb7e0c40
commit 3d5130d68d
1 changed files with 2 additions and 1 deletions

View File

@ -197,6 +197,7 @@ def get_flashed_messages_if_any():
s = '' s = ''
for message in messages: for message in messages:
s += '<div class="alert alert-warning" role="alert">' s += '<div class="alert alert-warning" role="alert">'
s += '<h4 class="alert-heading">Congratulations</h4>'
s += f'{message}' s += f'{message}'
s += '</div>' s += '</div>'
return s return s
@ -326,7 +327,7 @@ def familiar(username,word):
def deleteword(username,word): def deleteword(username,word):
user_freq_record = path_prefix + 'static/frequency/' + 'frequency_%s.pickle' % (username) user_freq_record = path_prefix + 'static/frequency/' + 'frequency_%s.pickle' % (username)
pickle_idea2.deleteRecord(user_freq_record,word) pickle_idea2.deleteRecord(user_freq_record,word)
flash(f'Congratulations! <strong>{word}</strong> is no longer in your word list.') flash(f'<strong>{word}</strong> is no longer in your word list.')
return redirect(url_for('userpage', username=username)) return redirect(url_for('userpage', username=username))
@app.route("/<username>", methods=['GET', 'POST']) @app.route("/<username>", methods=['GET', 'POST'])