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.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f493d364a192c26372df1c0880deacf3da0ddd56d7d8d25a680ec30f1cac51f4 |
|
MD5 | 5919368ae4dd393b3052902b69b0a0b0 |
|
BLAKE2b-256 | 5e7ba2ef28c5794ef2fe27a8d785239bcc3787ec465afdef45c058b56e7ccc59 |