Created
August 6, 2017 23:37
-
-
Save sphuff/fa088fbd78ea8944c75ece70089400ec to your computer and use it in GitHub Desktop.
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, 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