|
|
|
@ -12,12 +12,14 @@ import re |
|
|
|
|
import io |
|
|
|
|
import appdb, appsms |
|
|
|
|
import configparser |
|
|
|
|
from flask import Flask, render_template, request |
|
|
|
|
|
|
|
|
|
#from flask import Flask, render_template, request |
|
|
|
|
import flask |
|
|
|
|
|
|
|
|
|
######################## |
|
|
|
|
## Code starts here |
|
|
|
|
app = Flask(__name__) |
|
|
|
|
#app = Flask(__name__) |
|
|
|
|
app = flask.Blueprint('callback-sms', __name__) |
|
|
|
|
#app = flask.Flask(__name__) |
|
|
|
|
|
|
|
|
|
######### |
|
|
|
|
# This is so bare I don't need a config right now. |
|
|
|
@ -27,14 +29,14 @@ app_debug = config.get("app","debug") |
|
|
|
|
|
|
|
|
|
############################# |
|
|
|
|
## Callback defs go here |
|
|
|
|
@app.route('/') |
|
|
|
|
def index(): |
|
|
|
|
return render_template('index.html') |
|
|
|
|
#@app.route('/') |
|
|
|
|
#ef index(): |
|
|
|
|
# return render_template('index.html') |
|
|
|
|
|
|
|
|
|
@app.route('/sms-inbound', methods=['POST']) |
|
|
|
|
def smsinbound(): |
|
|
|
|
#extract attributes from POSTed JSON of inbound SMS |
|
|
|
|
json_content = request.json |
|
|
|
|
json_content = flask.request.json |
|
|
|
|
reply_to = json_content['data']['attributes']['from'] |
|
|
|
|
reply_from = json_content['data']['attributes']['to'] |
|
|
|
|
msg_id = json_content['data']['id'] |
|
|
|
@ -50,22 +52,10 @@ def smsinbound(): |
|
|
|
|
|
|
|
|
|
@app.route('/dlr', methods=['POST','GET']) |
|
|
|
|
def deliveryReport(): |
|
|
|
|
json_content = request.json |
|
|
|
|
json_content = flask.request.json |
|
|
|
|
pprint.pprint(json_content) |
|
|
|
|
msg_id = json_content['data']['id'] |
|
|
|
|
msg_status = json_content['data']['attributes']['status'] |
|
|
|
|
msg_timestamp = json_content['data']['attributes']['timestamp'] |
|
|
|
|
appdb.updateMsgStatus(msg_id, msg_status, msg_timestamp) |
|
|
|
|
return "0" |
|
|
|
|
|
|
|
|
|
################# |
|
|
|
|
## Main loop |
|
|
|
|
if __name__ == '__main__': |
|
|
|
|
if app_debug == '1': |
|
|
|
|
app.debug = True |
|
|
|
|
else: |
|
|
|
|
app.debug = False |
|
|
|
|
app.run( |
|
|
|
|
host="0.0.0.0", |
|
|
|
|
port=8790 |
|
|
|
|
) |