forked from abhisheksp/global-hack-7
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.py
46 lines (35 loc) · 1.11 KB
/
main.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
46
import firebase
from flask import Flask, request
from broadcast import broadcast
from register import register_group, register_number
app = Flask(__name__)
app.config["DEBUG"] = True
@app.route('/', methods=['GET'])
def home():
return '<h1>Works!</h1>'
@app.route('/broadcast', methods=['POST'])
def broadcast_handler():
request_body = request.get_json()
message = request_body['message']
status = broadcast(message)
return status
@app.route('/messagecallback', methods=['POST'])
def message_callback_handler():
message = request.values.get('Body', None)
from_number = request.values.get('From', None)
status = broadcast(from_number, message)
return status
@app.route('/register', methods=['POST'])
def register_handler():
request_body = request.get_json()
platform = request_body['platform']
identifier = request_body['identifier']
if platform == 'facebook':
print('calling FB')
status = register_group(identifier)
else:
print('calling Number')
status = register_number(identifier)
return status
if __name__ == '__main__':
app.run()