Created
August 7, 2012 03:51
-
-
Save whichlight/3281339 to your computer and use it in GitHub Desktop.
twilio snippet, using get and post
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 | |
import flask | |
from twilio.rest import TwilioRestClient | |
import re | |
import random | |
import twilio.twiml | |
import os | |
''' | |
A snippet of a twilio app, using GET and POST | |
on the main route ("/") to handle both SMS | |
and browser requests, for a blog post | |
on www.whichlight.com | |
''' | |
app = Flask(__name__) | |
account_sid = "" | |
auth_token = "" | |
@app.route("/", methods=['GET', 'POST']) | |
def hello(): | |
if flask.request.method=="POST": | |
resp = twilio.twiml.Response() | |
resp.sms(get_sample_text()) | |
return str(resp) | |
if flask.request.method=="GET": | |
txt = get_sample_text() | |
return flask.render_template('index.html', text=txt) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment