Skip to content

Instantly share code, notes, and snippets.

@RobSpectre
Created March 17, 2012 16:31
Show Gist options
  • Save RobSpectre/2061850 to your computer and use it in GitHub Desktop.
Save RobSpectre/2061850 to your computer and use it in GitHub Desktop.
Demonstration of conference creation with client
import flask
from twilio import twiml
from twilio.rest import TwilioRestClient
from twilio.util import TwilioCapability
import os
app = flask.Flask(__name__)
@app.route('/conference', methods=['POST'])
def conference():
response = twiml.Response()
with response.dial() as dial:
dial.conference("Hack The Change")
return str(response)
@app.route('/phone')
def phone():
client = TwilioRestClient(os.environ.get('ACCOUNT_SID'),
os.environ.get('AUTH_TOKEN'))
client.calls.create(from_="+12165862529", to="+14152038618",
url="http://karaoke.brooklynhacker.com/conference")
client.calls.create(from_="+12165862529", to="+12152720723",
url="http://karaoke.brooklynhacker.com/conference")
capability = TwilioCapability(os.environ.get('ACCOUNT_SID'),
os.environ.get('AUTH_TOKEN'))
capability.allow_client_outgoing('AP111486896c444e94bfca92f482861379')
token = capability.generate()
return flask.render_template('client.html', token=token)
if __name__ == "__main__":
port = int(os.environ.get('PORT', 5000))
app.debug = True
app.run(host='0.0.0.0', port=port)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment