-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython-backend.py
More file actions
29 lines (23 loc) · 915 Bytes
/
python-backend.py
File metadata and controls
29 lines (23 loc) · 915 Bytes
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
from flask import Flask, request, Response
from twilio.rest import TwilioRestClient
from twilio import twiml
app = Flask(__name__)
account = 'AC1ea915e8d2fb79d9efd01c53b94cdc75'
token = 'c72fde4d7af307c610aaa0e5f3c3c9e2'
client = TwilioRestClient(account, token)
@app.route("/")
def base():
call = client.calls.create(to='+447729837696',
from_='+441543624251',
url='http://logomache.in:5000/xml?username=%s' %
request.args['username'])
return ''
@app.route("/xml", methods=['POST'])
def xml():
r = twiml.Response()
r.say("Yo! Can you let %s in, please?" % request.args['username'].lower(),
voice='woman', language='en-gb')
r.dial(callerId='+447729837696')
return Response(str(r), mimetype='text/xml')
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=True)