-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsendsms.py
executable file
·34 lines (30 loc) · 1 KB
/
sendsms.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
from flask import Flask,request
from kavenegar import *
import sys
app = Flask(__name__)
@app.route('/sendsms',methods=['POST'])
def sensms():
try:
msg = request.get_json()
print(msg)
req_data = request.get_json()
dashboardId = req_data['dashboardId']
messageg = req_data['message']
ruleName = req_data['ruleName']
state = req_data['state']
title = req_data['title']
api = KavenegarAPI('TOKEN')
params = {
'sender': 'senderNUMBER',#optional
'receptor': '',#multiple mobile number, split by comma
'message': "dashboardId = {} \nmessageg = {} \nruleName = {} \nstate = {} \ntitle ={}".format(dashboardId, messageg, ruleName, state, title)
}
response = api.sms_send(params)
return(response)
except APIException as e:
return(e)
except HTTPException as e:
return(e)
#return "Hello World!"
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8088)