【发布时间】:2014-01-22 06:20:01
【问题描述】:
我正在关注有关通过 API 发送 SMS 的 Twilio 教程。我遵循了所有步骤,但是,我收到了 405 错误。我的代码:
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)
我在调用我的 url 时收到 405 错误(方法不允许),它看起来像:http://my-url.herokuapp.com/sms,它也像这样与 twilio 帐户相关联。当我包含“GET”时,一切正常,但这不是根据教程。有什么提示吗?
【问题讨论】:
-
该 URL 只有在你
POST的情况下才有效,如果你只是在浏览器中访问它,你会得到405因为 URL 仅映射为 POST .真正的问题是什么?
标签: python heroku flask twilio http-status-code-405