forked from evinh/apidaze-flask-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
55 lines (48 loc) · 1.6 KB
/
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
46
47
48
49
50
51
52
53
54
55
import logging
import datetime
from flask import Flask, request, redirect, make_response, render_template, url_for, jsonify, send_from_directory, Response
import json
import os
from jinja2 import Environment, PackageLoader
import requests
from flask_bootstrap import Bootstrap
from urlparse import urlparse, urlsplit, parse_qs, parse_qsl
import re
import time
env = Environment()
app = Flask(__name__, static_url_path = "/static", static_folder = "static")
Bootstrap(app)
#timestamp = str(datetime.datetime.now())
### apidaze Config
base_url = "https://api4.apidaze.io/"
## Demo Variables
api_key = "<YOUR API KEY>"
api_secret = "<YOUR API SECRET>"
number = "<YOUR APIDAZE NUMBER>"
def timeformat(value, format='%H:%M / %d-%m-%Y'):
return value.strftime(format)
@app.route('/receiveSMS')
def inbound_sms(rec_name):
url = request.url
app_url = request.host_url
this_url = request.base_url
fromnumber = str(request.args.get('caller_id_number'))
tonumber = request.args.get('destination_number')
ts = int(time.time())
return url
@app.route('/recieveCall')
def inbound_call():
url = request.url
app_url = request.host_url
this_url = request.base_url
fromnumber = str(request.args.get('caller_id_number'))
tonumber = request.args.get('destination_number')
ts = int(time.time())
example_variable = "stuff"
template = render_template('call.xml', some_variable=example_variable)
response = make_response(template)
response.headers['Content-Type'] = 'text/xml'
return response
if __name__ == "__main__":
app.debug = True
app.run(host="0.0.0.0", port=5000)