简体   繁体   English

在Amazon EC2上运行Python RESTful API

[英]Running Python RESTful API on Amazon EC2

I have a working RESTful API written in python which works well in my local machine. 我有一个使用python编写的有效RESTful API,在我的本地计算机上运行良好。 Now I am having some serious trouble getting started with Amazon EC2. 现在,我在使用Amazon EC2时遇到了一些严重的麻烦。 I have managed to create an account and managed to create an instance , and lauch the instance as well. 我已经成功创建了一个帐户并成功创建了一个实例,并且也对该实例进行了匿名处理。 I have connected to the instance via ssh and passed by credentials. 我已通过ssh连接到实例并通过凭据传递。 I have the required file (app.py) on EC2. 我在EC2上具有所需的文件(app.py)。 But I have no idea how to run it. 但是我不知道如何运行它。 Obviously if I run it from my ssh terminal, it still is a local service. 显然,如果我从ssh终端运行它,它仍然是本地服务。

How to make it a public RESTful API? 如何使其成为公共的RESTful API?

Like a firewall, you have to open up the server's ports. 就像防火墙一样,您必须打开服务器的端口。 You do this via adding rules to the security group while you're configuring the EC2 instance. 在配置EC2实例时,可以通过向安全组中添加规则来做到这一点。 Add the HTTP rule, and allow all IP addresses (0.0.0.0/0) to access that. 添加HTTP规则,并允许所有IP地址(0.0.0.0/0)进行访问。 See here: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html#adding-security-group-rule 参见此处: http : //docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html#adding-security-group-rule

You can also set SSH, HTTPS, and other secure ports here (but you probably don't want everyone accessing SSH!). 您还可以在此处设置SSH,HTTPS和其他安全端口(但您可能不希望每个人都访问SSH!)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM