Created
May 21, 2012 23:19
-
-
Save RobSpectre/2765341 to your computer and use it in GitHub Desktop.
Example of Plays and Redirects together
This file contains hidden or 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 | |
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