Slack Python |
- requirements.txt - Procfile - runtime.txt
httplib2
slacker
Flask==0.12
, PyCharm , - .web: python app.py
from flask import Flask
from flask import request
from flask import make_response
app = Flask(__name__)
#
@app.route('/webhook')
def hello_slack():
#
request_json = request.get_json(silent=True, force=True)
# dict ,
# request_json -> response_body_json
...
response_body = json.dumps(response_body_json)
#
response = make_response(response_body)
response.headers['Content-Type'] = 'application/json'
#
return response
if __name__ == '__main__':
port = int(os.getenv('PORT', 5000))
app.run(debug=False, port=port, host='0.0.0.0')
https://YOUR_APP_NAME.herokuapp.com/webhook, *---*. events API ( , ). challenge-request . - Event Subscriptions . . , , . , /auth, , . , POST- slack.com/api/oauth.access , , , .
language: python
python:
- "3.6"
script:
python3 -m unittest discover
script , , . ( ) - .