bottle-flash-0.1
توضیحات
flash plugin for bottle
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | bottle-flash-0.1 |
| نام | bottle-flash |
| نسخه کتابخانه | 0.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Ajeet Grewal |
| ایمیل نویسنده | asgrewal@gmail.com |
| آدرس صفحه اصلی | https://github.com/agreatjewel/bottle_plugins/tree/master/bottle_flash |
| آدرس اینترنتی | https://pypi.org/project/bottle-flash/ |
| مجوز | MIT |
bottle_flash
============
This plugin enables flash messages in bottle. Again, learn by example
::
from bottle import Bottle
from bottle_flash import FlashPlugin
app = Bottle()
COOKIE_SECRET = 'super_secret_string'
app.install(FlashPlugin(secret=COOKIE_SECRET))
app.post('/create_user')
def create_user():
# Create the user
app.flash('Created !')
To consume the flashed messages, you would do something like the following (jinja2). Here I am assuming that I get the "app" in the template context. This can be achieved with the bottle_renderer_ plugin.
::
{% set messages = app.get_flashed_messages() %}
{% if messages %}
<div id="flash_messages">
<ul>
{% for m in messages %}
<li>{{ m[0] }}</li>
{% endfor %}
</ul>
</div>
{% endif %}
نحوه نصب
نصب پکیج whl bottle-flash-0.1:
pip install bottle-flash-0.1.whl
نصب پکیج tar.gz bottle-flash-0.1:
pip install bottle-flash-0.1.tar.gz