Skip to content

Instantly share code, notes, and snippets.

@sphuff
Created August 6, 2017 23:37
Show Gist options
  • Save sphuff/fa088fbd78ea8944c75ece70089400ec to your computer and use it in GitHub Desktop.
Save sphuff/fa088fbd78ea8944c75ece70089400ec to your computer and use it in GitHub Desktop.
from flask import Flask, request
from twilio.twiml.messaging_response import MessagingResponse
from random import randint
app = Flask(__name__)
@app.route('/sms', methods=['POST'])
def sms():
number = request.form['From']
message_body = request.form['Body']
resp = MessagingResponse()
if message_body.find('|') == -1:
print("did not find pipe")
resp.message("Not a proper heads/tails")
else:
arr = message_body.split('|')
randInt = randint(0, 1)
print("found pipe")
resp.message(arr[randInt])
return str(resp)
if __name__ == '__main__':
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment