Skip to content

Instantly share code, notes, and snippets.

@whichlight
Created August 7, 2012 03:51
Show Gist options
  • Save whichlight/3281339 to your computer and use it in GitHub Desktop.
Save whichlight/3281339 to your computer and use it in GitHub Desktop.
twilio snippet, using get and post
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