Last active
November 3, 2016 22:26
-
-
Save neanias/59141fe341f1e0271809 to your computer and use it in GitHub Desktop.
AT Labs Backend in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, request, Response | |
from twilio.rest import TwilioRestClient | |
from twilio import twiml | |
app = Flask(__name__) | |
account = 'Insert SID here' | |
token = 'Auth token' | |
client = TwilioRestClient(account, token) | |
@app.route("/") | |
def base(): | |
call = client.calls.create(to='+lab-phone-number', | |
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='+lab-phone-number') | |
return Response(str(r), mimetype='text/xml') | |
if __name__ == '__main__': | |
app.run(host='0.0.0.0', debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flask | |
twilio |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment