Example #1
0
# slack_blueprint.py
from flask import Blueprint
from slackify import Slackify, reply_text

bp = Blueprint('slackify_bp', __name__, url_prefix='/slack')
slackify = Slackify(app=bp)


@slackify.command
def hello():
    return reply_text('Hello from a blueprint')


# app.py
from flask import Flask
# from slack_blueprint import bp

def create_app():
    app = Flask(__name__)
    app.register_blueprint(bp)
    return app
Example #2
0
from flask import Flask
from slackify import Slackify, request, text_block, Slack, ACK
import json

# Important! Before running set FLASK_APP=examples.async_task:app
app = Flask(__name__)
slackify = Slackify(app=app)
cli = Slack('xoxb-SECRET-TOKEN')


@slackify.command
def register():
    username_input_block = {
        "type": "input",
        "block_id": "username_block",
        "element": {
            "type": "plain_text_input",
            "placeholder": {
                "type": "plain_text",
                "text": "Enter your username"
            },
            "action_id": "username_value"
        },
        "label": {
            "type": "plain_text",
            "text": "👤 Username",
            "emoji": True
        }
    }
    password_input_block = {
        "type": "input",
Example #3
0
def test_we_cant_use_a_bp_with_no_url_prefix():
    with pytest.raises(
            ValueError,
            match="Missing required 'url_prefix' for blueprint TestBlueprint"):
        no_prefix_bp = Blueprint('TestBlueprint', __name__)
        Slackify(app=no_prefix_bp)