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-sqlalchemy
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.
BlackSheep-Messages
Extension for BlackSheep that similiar with flask flashes messages
d6ed37df41252e9d131920da2f3b133417ae4f76
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.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85c78243b10703105c4c23e7f0250f55a3b5f90bad062576d593c3e9627d6749 |
|
MD5 | 4b3ac643967bf29b0b8b531b76d6b77d |
|
BLAKE2b-256 | a6ab6e3d68ee7f265ae4911cfcafc5aee0dc5591fb6fbca2affbe54ae91f5802 |