Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

blacksheep-messages-1.0.3.tar.gz (3.6 kB view details)

Uploaded Source

File details

Details for the file blacksheep-messages-1.0.3.tar.gz.

File metadata

  • Download URL: blacksheep-messages-1.0.3.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for blacksheep-messages-1.0.3.tar.gz
Algorithm Hash digest
SHA256 f493d364a192c26372df1c0880deacf3da0ddd56d7d8d25a680ec30f1cac51f4
MD5 5919368ae4dd393b3052902b69b0a0b0
BLAKE2b-256 5e7ba2ef28c5794ef2fe27a8d785239bcc3787ec465afdef45c058b56e7ccc59

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page