python flask flash消息闪现
生活随笔
收集整理的這篇文章主要介紹了
python flask flash消息闪现
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
flash 消息閃現
很多人都不用flash這個組件,其實特別好用。
好的應用和用戶界面的重點是回饋。如果用戶沒有得到足夠的反饋,他們可能最終會對您的應用產生不好的評價。Flask 提供了一個非常簡單的方法來使用閃現系統向用戶反饋信息。閃現系統使得在一個請求結束的時候記錄一個信息,然后在且僅僅在下一個請求中訪問這個數據。這通常配合一個布局模板實現。
具體請查看: http://docs.jinkan.org/docs/flask/patterns/flashing.html
標準的bootstrap
template html
利用bootstrap的類的方法名來做這類的事情
success : 為綠色的
danger : 為紅色的
warning : 為×××的
/templates/flash.html
<body class="gray-bg"> <!--通知消息處-->{% with messages = get_flashed_messages(with_categories=true) %}{% if messages %}{% for category, message in messages %}<div class="alert alert-{{ category }}" style="text-align: center"><button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button><strong>{{ message }}</strong></div>{% endfor %}{% endif %}{% endwith %} </body>controller action
下一個訪問請求之中獲取這個數據
/main.py
總結
以上是生活随笔為你收集整理的python flask flash消息闪现的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 将本地SHH文件导入SourceTree
- 下一篇: Java 设计模式之单利模式