Hi all I'm trying to setup a AWS cloud9 environment with flask to develop a web app. I'm new to AWS/ flask, and stuck on an issue. There seems to be an issue between the IDE environment and previewing the application in my browser (I'm using chrome, but have also tried in IE).
From app.py:
import os
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return 'Hello World'
app.run(host=os.getenv('IP', '0.0.0.0'), port=int(os.getenv('PORT', 8080)))
if __name__ == '__main__':
app.run()
app.debug(True)
When I run this in the terminal (as root):
[root@ip-172-31-11-201 environment]# python ./app.py
Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)
When I right click on the on http://0.0.0.0:8080/
it will open a yab and redirect me to a Public IP x.x.x.x:8080
and will eventually timeout and give me:
err_connection_timeout
When I attempt to run the application using the IDE run option it will take me to:
Running on http://127.0.0.1:8080/ (Press CTRL+C to quit)
At which point it will just timeout as well. So this has me really confused, when I'm running this outside of the cloud9 IDE I don't have this issue. I know in the documentation you're supposed to point to 0.0.0.0 over port 8080. So I'm not quite sure why running that with run would change the IP I specified.
I've also tried manually putting my project and username in manually:
At which point it redirects me to a page where it tells me it "can't find my username". I then tried to setup a cloud9.io account which completed, I confirmed my account but can't login and still have the "cannot find username" page.
After which I tested my app.py
file from cloud9 locally with sublime substituted 0.0.0.0
for 127.0.0.1
and it worked locally.
Does is there anything I'm missing in my config? Has anything changed in the setup since AWS acquired cloud9, I've been following online tutorials and videos but just can't see to solve this issue.
From the IDE environment:
# python --version
Python 2.7.12
# pip freeze flask
astroid==1.5.3
aws-cfn-bootstrap==1.4
awscli==1.11.132
Babel==0.9.4
backports.functools-lru-cache==1.4
backports.ssl-match-hostname==3.4.0.2
boto==2.42.0
botocore==1.5.95
chardet==2.0.1
click==6.7
cloud-init==0.7.6
CodeIntel==0.9.3
colorama==0.2.5
configobj==4.7.2
configparser==3.5.0
docutils==0.11
ecdsa==0.11
enum34==1.1.6
Flask==0.12.2
futures==3.0.3
gyp==0.1
ikpdb==1.1.2
Inflector==2.0.11
iniparse==0.3.1
isort==4.2.15
itsdangerous==0.24
jedi==0.11.0
Jinja2==2.7.2
jmespath==0.9.2
jsonpatch==1.2
jsonpointer==1.0
kitchen==1.1.1
lazy-object-proxy==1.3.1
lockfile==0.8
MarkupSafe==0.11
mccabe==0.6.1
paramiko==1.15.1
parso==0.1.0
PIL==1.1.6
ply==3.4
pyasn1==0.1.7
pycrypto==2.6.1
pycurl==7.19.0
pygpgme==0.3
pyliblzma==0.5.3
pylint==1.7.4
pylint-django==0.7.2
pylint-flask==0.5
pylint-plugin-utils==0.2.6
pystache==0.5.3
python-daemon==1.5.2
python-dateutil==2.1
pyxattr==0.5.0
PyYAML==3.10
requests==1.2.3
rsa==3.4.1
simplejson==3.6.5
singledispatch==3.4.0.3
six==1.11.0
subprocess32==3.2.7
urlgrabber==3.10
urllib3==1.8.2
virtualenv==15.1.0
Werkzeug==0.13
wrapt==1.10.11
yum-metadata-parser==1.1.4
zope.cachedescriptors==4.3.0
Thanks for any help!