Skip to content

Instantly share code, notes, and snippets.

@pebblexe
Created February 7, 2017 15:20
Show Gist options
  • Save pebblexe/45a3ff9c57c82ff26df613d58ca5a5dd to your computer and use it in GitHub Desktop.
Save pebblexe/45a3ff9c57c82ff26df613d58ca5a5dd to your computer and use it in GitHub Desktop.
from twilio.rest import TwilioRestClient
from flask import Flask
from flask import request
import pprint
pp = pprint.PrettyPrinter(indent=4)
app = Flask(__name__)
account_sid = 'AC...';
auth_token = '4c...';
client = TwilioRestClient(account_sid, auth_token)
message = client.messages.create(body="Hello from Python",
to="+13...", # Replace with your phone number
from_="+18...") # Replace with your Twilio number
@app.route('/', methods=['GET', 'POST'])
def parse_request():
data = request.data # data is empty
body = request.args.get("Body")
from2 = request.args.get("From")
response = "From: " + from2 + ", Body:" + body
message = client.messages.create(body=response,
to="+14...", # Replace with your phone number
from_="+18...") # Replace with your Twilio number
print body
print from2
return "Hello!"
if __name__ == "__main__":
app.run(host='0.0.0.0', port=80)
print(message.sid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment