python flask flash消息闪现
2017-12-01 14:57
309 查看
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
app.route("flash")
def view_flash()
flash(message, action)
action = ["success", 'error', 'danger'] ...
return render_template("flash.html")
很多人都不用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
app.route("flash")
def view_flash()
flash(message, action)
action = ["success", 'error', 'danger'] ...
return render_template("flash.html")
相关文章推荐
- python web开发-flask中消息闪现flash的应用
- python flask flash消息闪现
- Flask-过滤消息闪现
- Flask中的flash消息
- Flask -- 消息闪现、错误处理
- Flask 使用消息闪烁(flash)报错:The session is unavailable because no secret key was set。。。
- Flask 使用消息闪烁(flash)报错
- flask之闪现flash的使用
- Flask从入门到精通之Flash消息
- 用flask开发个人博客(17)—— Flash消息
- python flask 笔记记录
- python3及wxpythonGUI多线程防假死与线程消息传递消息(最新)
- Python的Flask框架中实现简单的登录功能的教程
- 用python flask搭建一个网站[一]——服务器程序
- 解决python中flask_sqlalchemy包安装失败的问题
- python flask下传数据到js
- python应用部署--flask
- Flask 学习篇一: 搭建Python虚拟环境,安装flask,并设计RESTful API。
- python 发送soap消息
- Python Flask使用Nginx做代理时如何获取真实IP