【发布时间】:2020-12-05 20:01:28
【问题描述】:
flask、ngrok 和 twilio 的初学者。我运行了这段 python 代码来为 twilio 创建一个烧瓶应用程序:
from flask import Flask, request, redirect
from twilio.twiml.messaging_response import MessagingResponse
app = Flask(__name__)
@app.route("/sms", methods=['GET', 'POST'])
def incoming_sms():
"""Send a dynamic reply to an incoming text message"""
# Get the message the user sent our Twilio number
body = request.values.get('Body', None)
# Start our TwiML response
resp = MessagingResponse()
# Determine the right reply for this message
if body == 'hello':
resp.message("Hi!")
elif body == 'bye':
resp.message("Goodbye")
return str(resp)
if __name__ == "__main__":
app.run(debug=True)
然后我运行“ngrok http http://127.0.0.1:5000" 创建一个 ngrok 链接,但是当我使用它时,我得到 404 未找到。是什么导致了这个问题,我该如何解决?
更新:http://127.0.0.1:5000/sms 不起作用,显示空白页
【问题讨论】:
-
http://127.0.0.1:4040/sms上你有什么? -
您是按原样尝试 ngrok 链接,还是添加
/sms?如果你没有,它应该有 404'd,因为你没有'/'的路线。 -
我跑了代码,这次我发/sms的时候屏幕是空白的
-
右键单击您的网络浏览器并查看源代码,输出为 Twilio Markup Language (TwiML)。
-
嗨,当我尝试127.0.0.1:4040/sms 版本时,输出是
标签: python flask twilio http-status-code-404 ngrok