-
Notifications
You must be signed in to change notification settings - Fork 0
/
start-server.py
executable file
·51 lines (37 loc) · 999 Bytes
/
start-server.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
47
48
49
50
51
from flask import Flask, jsonify
from flask import request as rq
import json
import way2sms
app = Flask(__name__)
config_params = None
try:
with open("sms-server.conf", "r") as _file:
config_params = json.load(_file)
except:
print "Error: sms-server.conf missing!"
exit()
username, password = None, None
try:
username = config_params['username']
password = config_params['password']
except:
print "Error: username or password fields missing in sms-server.conf!"
exit()
proxies = None
try:
proxies = config_params['proxy']
except:
pass
q = way2sms.sms(username, password,proxies=proxies)
@app.route("/sendsms", methods=['GET'])
def send_sms():
mobile_number = rq.args.get('number')
message = rq.args.get('message')
if mobile_number == None or message == None:
return "Invalid request"
numbers = mobile_number.split(",")
response = []
for num in numbers:
response.append(q.send(num, message))
return jsonify(response=response)
app.run(debug = True, host="0.0.0.0")