-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
45 lines (32 loc) · 906 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
40
41
42
43
44
45
from flask import abort, Flask, request, Response
SECRET = 'fictional-spoon-crispy-waffle'
app = Flask(__name__)
@app.route('/hook', methods=['OPTIONS'])
def subscribe():
secret = request.args.get('secret')
if not secret:
abort(401)
if secret != SECRET:
abort(403)
headers = {
'allow': 'OPTIONS, POST',
'WebHook-Allowed-Origin': '*',
'WebHook-Allowed-Rate': 100,
}
return Response(headers=headers)
@app.route('/hook', methods=['POST'])
def process():
secret = request.args.get('secret')
if not secret:
abort(401)
if secret != SECRET:
abort(403)
full_request = (
f'{request.method} {request.url}\n'
f'{request.headers}\n'
f'{request.data}'
)
print('---------------------------')
print(full_request)
print('---------------------------')
return Response()