-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
39 lines (27 loc) · 766 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# -*- coding: utf-8 -*-
from libs import setup, logger, handle
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.before_first_request
def initialize():
setup.credentials()
@app.route('/', methods=['GET'])
def index():
logger.info('Hello World!')
return jsonify('Hello World!')
# handles Slack's challenge
@app.route('/challenge', methods=['POST'])
def challenge():
r = request.get_json()
logger.info(r)
# respond to Slack's challenge
if 'challenge' in r:
return r['challenge']
# capture events
if 'event' in r:
return handle.event(r['event'])
logger.error(f"unexpected request received: {r}")
return r
# main
if __name__ == "__main__":
app.run(host='0.0.0.0', port=5000)