Skip to content

Instantly share code, notes, and snippets.

@RobSpectre
Created May 21, 2012 23:19
Show Gist options
  • Save RobSpectre/2765341 to your computer and use it in GitHub Desktop.
Save RobSpectre/2765341 to your computer and use it in GitHub Desktop.
Example of Plays and Redirects together
from flask import Flask
from twilio import twiml
# Declare and configure application
app = Flask(__name__, static_url_path='/static')
# Voice Request URL
@app.route('/voice', methods=['GET', 'POST'])
def voice():
response = twiml.Response()
response.play("/static/jad0002a.wav")
response.play("/static/jad0002a.wav")
response.play("/static/jad0002a.wav")
response.play("/static/jad0002a.wav")
response.redirect("/doh")
return str(response)
@app.route('/doh', methods=['POST'])
def doh():
response = twiml.Response()
response.play("/static/ramones.mp3")
return str(response)
# If PORT not specified by environment, assume development config.
if __name__ == '__main__':
port = int(os.environ.get("PORT", 5000))
if 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