[英]How to migrate Twilio Python Script to AWS EC2 using Flask
I have built a SMS service (using Twilio) that the user texts to get realtime bus information. 我已经建立了一个SMS服务(使用Twilio),用户可以通过短信获取实时公交信息。 At the moment i have been hosting this on my personal computer using ngrok.
目前,我已经使用ngrok将其托管在我的个人计算机上。 Now i want to use AWS to host this service, but I am not sure as to how i should go about it.
现在,我想使用AWS托管此服务,但是我不确定应该如何处理。 I have tried running a flask webserver and trying to get ngrok to run on AWS, but no luck.
我尝试过运行Flask Web服务器,并尝试让ngrok在AWS上运行,但是没有运气。
Here is my code concerning Flask and Twilio's REST Api: 这是我关于Flask和Twilio的REST Api的代码:
app = Flask(__name__)
@app.route("/sms", methods=['GET', 'POST'])
def hello_monkey():
resp = MessagingResponse()
response = request.form['Body']
if (" " in response):
response = response.split(" ")
result = look_up(response[0], response[1])
else:
result = look_up(response, False)
resp.message(result)
return str(resp)
if __name__ == "__main__":
app.run(debug=True)
There is a blog post on the Twilio blog on How to Send SMS Text Messages with AWS Lambda and Python 3.6 . Twilio博客上有一篇博客文章,内容涉及如何使用AWS Lambda和Python 3.6发送SMS文本消息 。 It does not use Flask, but it can definitely be modified to achieve your goal.
它不使用Flask,但是绝对可以对其进行修改以实现您的目标。 Alternatively, you could read about using Flask with AWS Elastic Beanstalk here .
或者,您可以在此处阅读有关结合使用Flask和AWS Elastic Beanstalk的信息 。
Running ngrok on AWS is not the correct approach to this. 在AWS上运行ngrok并不是正确的方法。 If you wanted to host your own Flask server, you could use something like Lightsail , but that's overkill for this usage.
如果您想托管自己的Flask服务器,则可以使用Lightsail之类的东西 ,但这对于这种用法来说是过高的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.