Reputation: 5627
I was following a Twilio tutorial on sending SMS through the API. I followed all the steps, however, I am receiving a 405 error. My code:
from flask import Flask
from twilio import twiml
import os
app = Flask(__name__)
@app.route('/sms', methods=['POST'])
def sms():
r = twiml.Response()
r.sms("This is awesome!")
return str(r)
if __name__ == '__main__':
port = int(os.environ.get('PORT', 5000))
if port == 5000:
app.debug = True
app.run(host='0.0.0.0', port=port)
I am getting a 405 error (method not allowed), when calling my url, which looks like: http://my-url.herokuapp.com/sms, which is also associated like this to the twilio account. When I include 'GET', everything works, this is not according to tutorial however. Any hints?
Upvotes: 0
Views: 2905
Reputation: 159915
Looking at the repository it seems that you will actually need to text to the number that Twillo is proxying for you. If you want to access the URL in your browser as well you will need to add 'GET'
to the methods
list (as you discovered).
Upvotes: 2