blacksheep-messages-1.0.3
توضیحات
Extension for BlackSheep that similiar with flask flashes messages
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | blacksheep-messages-1.0.3 |
| نام | blacksheep-messages |
| نسخه کتابخانه | 1.0.3 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Riordan Ganezo |
| ایمیل نویسنده | black.ganezo@gmail.com |
| آدرس صفحه اصلی | https://github.com/riordanz/BlackSheep-Messages |
| آدرس اینترنتی | https://pypi.org/project/blacksheep-messages/ |
| مجوز | MIT |
# BlackSheep-Messages
Extension for [BlackSheep](https://github.com/Neoteroi/BlackSheep) that similar with flask flashes message
```bash
pip install blacksheep-messages
```
## How to use (BlackSheep MVC)
First, set your web_url on settings.yaml
```yaml
app_name: Your Website
web_url: http://localhost:8000
```
Then, you can import BlackSheep Messages on server.py
```python
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
```python
@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
```jinja2
{% 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.
نحوه نصب
نصب پکیج whl blacksheep-messages-1.0.3:
pip install blacksheep-messages-1.0.3.whl
نصب پکیج tar.gz blacksheep-messages-1.0.3:
pip install blacksheep-messages-1.0.3.tar.gz