Skip to content

Commit 9509d08

Browse files
committed
Add Flask app sample that runs on Heroku
1 parent d2a6e36 commit 9509d08

3 files changed

Lines changed: 38 additions & 0 deletions

File tree

samples/heroku/Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: gunicorn --bind :$PORT --workers 1 --threads 2 --timeout 0 main:flask_app

samples/heroku/main.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import logging
2+
3+
from slack_bolt import App
4+
5+
logging.basicConfig(level=logging.DEBUG)
6+
app = App()
7+
8+
9+
@app.command("/hello-bolt-python-heroku")
10+
def hello(payload, ack):
11+
user_id = payload["user_id"]
12+
ack(f"Hi <@{user_id}>!")
13+
14+
15+
from flask import Flask, request
16+
from slack_bolt.adapter.flask import SlackRequestHandler
17+
18+
flask_app = Flask(__name__)
19+
handler = SlackRequestHandler(app)
20+
21+
22+
@flask_app.route("/slack/events", methods=["POST"])
23+
def slack_events():
24+
return handler.handle(request)
25+
26+
# heroku login
27+
# heroku create
28+
# git remote add heroku https://git.heroku.com/xxx.git
29+
30+
# export $SLACK_BOT_TOKEN=xxx
31+
# export SLACK_SIGNING_SECRET=xxx
32+
# heroku config:set SLACK_BOT_TOKEN=$SLACK_BOT_TOKEN
33+
# heroku config:set SLACK_SIGNING_SECRET=$SLACK_SIGNING_SECRET
34+
# git push heroku main

samples/heroku/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
slack_bolt
2+
Flask>=1.1
3+
gunicorn>=20

0 commit comments

Comments
 (0)