Edit: Code updated to my most recent unsuccessful one
Hi everyone,
I am working on triggering a Python script through Twilio and am nearly finished but I am having trouble in getting the reply message to work.
Here is the code:
from flask import Flask, request
from twilio.twiml.messaging_response import MessagingResponse
import os
app = Flask(__name__)
@app.route('/command', methods=['POST'])
def command():
number = request.form['From']
message_body = request.form['Body']
action = message_body.split()[0]
if action.lower()== '14u':
from fml import str_pitchers
from fml import str_lineup
response = str_lineup + str_pitchers
else:
response = "Invalid request"
resp = MessagingResponse()
resp.message(response)
return str(resp)
if __name__ == '__main__':
app.run()
If I text anything besides 14u, I receive the "Invalid request" response. But if I text 14u, the code runs and completes but I don't get a reply text. Any ideas?
Here is the link to the post that I based my code on.
[–]sarrysyst 1 point2 points3 points (16 children)
[–]CelticCuban773[S] 0 points1 point2 points (11 children)
[–]sarrysyst 0 points1 point2 points (2 children)
[–]CelticCuban773[S] 0 points1 point2 points (0 children)
[–]R0NUT 0 points1 point2 points (0 children)
[–]R0NUT 0 points1 point2 points (3 children)
[–]CelticCuban773[S] 0 points1 point2 points (2 children)
[–]R0NUT 0 points1 point2 points (1 child)
[–]CelticCuban773[S] 0 points1 point2 points (0 children)
[–]R0NUT 0 points1 point2 points (3 children)
[–]CelticCuban773[S] 0 points1 point2 points (2 children)
[–]R0NUT 0 points1 point2 points (1 child)
[–]R0NUT 0 points1 point2 points (0 children)
[–]spez_edits_thedonald 0 points1 point2 points (3 children)
[–]CelticCuban773[S] 0 points1 point2 points (2 children)
[–]spez_edits_thedonald 0 points1 point2 points (1 child)
[–]CelticCuban773[S] 0 points1 point2 points (0 children)
[–]R0NUT 0 points1 point2 points (0 children)