带烧瓶的AWS(端口通道)

时间:2013-03-07 12:41:50

标签: python amazon-web-services flask

我正在运行AWS实例。通过SimpleHTTPServer服务。

[ec2-user@ip-XXXXX ~]$ python -m SimpleHTTPServer 8080
Serving HTTP on 0.0.0.0 port 8080 ...
p54A5C877.dip0.t-XXX.org - - [07/Mar/2013 12:36:45] "GET / HTTP/1.1" 200 -

但是随后烧瓶,请求不会通过。

>>> from flask import Flask
>>> 
>>> app = Flask(__name__)
>>> 
>>> @app.route('/')
... def hello_world():
...     return 'Hello World!'
... 
>>> if __name__ == '__main__':    
...     app.run(port=8080)
... 
 * Running on http://127.0.0.1:8080/ => no request catched

1 个答案:

答案 0 :(得分:3)

经过一段时间的困惑之后,我发现了一分钟后我找到了解决方案。主机必须为0.0.0.0

app.run(port=8080,host='0.0.0.0')