Module slack_bolt.adapter.flask

Expand source code
from .handler import SlackRequestHandler

__all__ = [
    "SlackRequestHandler",
]

Sub-modules

slack_bolt.adapter.flask.handler

Classes

class SlackRequestHandler (app: App)
Expand source code
class SlackRequestHandler:
    def __init__(self, app: App):  # type: ignore
        self.app = app

    def handle(self, req: Request) -> Response:
        if req.method == "GET":
            if self.app.oauth_flow is not None:
                oauth_flow: OAuthFlow = self.app.oauth_flow
                if req.path == oauth_flow.install_path:
                    bolt_resp = oauth_flow.handle_installation(to_bolt_request(req))
                    return to_flask_response(bolt_resp)
                elif req.path == oauth_flow.redirect_uri_path:
                    bolt_resp = oauth_flow.handle_callback(to_bolt_request(req))
                    return to_flask_response(bolt_resp)
        elif req.method == "POST":
            bolt_resp: BoltResponse = self.app.dispatch(to_bolt_request(req))
            return to_flask_response(bolt_resp)

        return make_response("Not Found", 404)

Methods

def handle(self, req: flask.wrappers.Request) ‑> flask.wrappers.Response
Expand source code
def handle(self, req: Request) -> Response:
    if req.method == "GET":
        if self.app.oauth_flow is not None:
            oauth_flow: OAuthFlow = self.app.oauth_flow
            if req.path == oauth_flow.install_path:
                bolt_resp = oauth_flow.handle_installation(to_bolt_request(req))
                return to_flask_response(bolt_resp)
            elif req.path == oauth_flow.redirect_uri_path:
                bolt_resp = oauth_flow.handle_callback(to_bolt_request(req))
                return to_flask_response(bolt_resp)
    elif req.method == "POST":
        bolt_resp: BoltResponse = self.app.dispatch(to_bolt_request(req))
        return to_flask_response(bolt_resp)

    return make_response("Not Found", 404)