0

I'm following a mooc for building quickly a website in flask. I'm using Cloud9 but i'm unable to watch my preview on it, i get an :

"Unable to load http preview" :

the code is really simple, here the views.py code

from flask import Flask, render_template

app = Flask(__name__)
# Config options - Make sure you created a 'config.py' file.
app.config.from_object('config')
# To get one variable, tape app.config['MY_VARIABLE']

@app.route('/')
def index():
    return "Hello world !"

if __name__ == "__main__":
    app.run()

And the preview screen, is what I get when I execute

python views.py

Thank you in advance

Druta Ruslan
  • 7,171
  • 2
  • 28
  • 38
Chrys Bltr
  • 68
  • 3
  • 13

2 Answers2

0

you need to make FLASK_APP environment variable, and flask application is not running like python views.py but flask run. Quick start

# give an environment variable, give the absolute path or relative 
# path to you flask app, in your case it is `views.py`
export FLASK_APP=views.py

#after this run flask application
flask run
Druta Ruslan
  • 7,171
  • 2
  • 28
  • 38
  • thanks for you answer but i got the same result with your method. When I tried to do it on my physical computer and not on cloud9, it worked. So I guess the probleme should come from cloud9 initial access settings . – Chrys Bltr Jun 17 '18 at 18:22
0

I faced the same problem. There is no way we can preview http endpoints directly. Although in AWS documentation they have asked to follow certain steps, but those too wont work. Only way is to access it using instance public address and exposing required ports. Read here for this.

Shubham Takode
  • 525
  • 8
  • 24