Extension for BlackSheep that similiar with flask flashes messages
Project description
BlackSheep-Messages
Extension for BlackSheep that similar with flask flashes message
pip install blacksheep-messages
How to use (BlackSheep MVC)
First, set your web_url on settings.yaml
app_name: Your Website
web_url: http://localhost:8000
Then, you can import BlackSheep Messages on server.py
from app.configuration import load_configuration
from app.program import configure_application
from app.services import configure_services
from blacksheep_messages import use_blacksheep_message
if uvloop is not ...:
uvloop.install()
app = configure_application(*configure_services(load_configuration()))
use_blacksheep_message(app, load_configuration())
After registering BlackSheep Messages, services are configured in the application, so they are automatically resolved in any request handler requiring a parameter named bs_message
@post("/register")
async def register_action(bs_message):
if True:
bs_message.add("No Error", "success")
else:
bs_message.add("Error found", "error")
Than you can get message using bs_message(category)
on jinja2 template
{% if bs_message("success", check=True) %}
{% for msg in bs_message("success") %}
{{ msg }}
{% endfor %}
{% endif %}
{% if bs_message("error", check=True) %}
{% for msg in bs_message("error") %}
{{ msg }}
{% endfor %}
{% endif %}
Note : set check value to True to avoid message deleted automatically.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for blacksheep-messages-1.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0f668b6346460833a557a5fff263ad16f388e34fa92436b9affbef86aace4b3 |
|
MD5 | e17a48937263704830b5f74a3c4bfa2b |
|
BLAKE2b-256 | 82986ea1f21a83dc57c855dcc8cd404016594a9dfda674a9b5e4512588f5d58a |