[PYTHON] Flask Hello World cannot be displayed on VPS

Background

I tried to build a Flask environment with VPS instead of a local environment and run Hello World, but I couldn't.

Solution

I was able to connect by specifying host in ʻapp.run`. http://example.com:8000

hello.py


import flask

app = flask.Flask(__name__)

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

if __name__ == '__main__':
    app.run(host='0.0.0.0',port=8000)

python


$ python hello.py
 * Running on http://0.0.0.0:8000/ (Press CTRL+C to quit)

Cause

It wasn't a problem with the local environment. I should have noticed it when I ran it and displayed http://127.0.0.1 on the terminal, but it was a story I didn't notice.

If you want to access from a server other than the one you have started, specify it with host =.

Recommended Posts

Flask Hello World cannot be displayed on VPS
Hello World on Django
Hello world with flask
Hello World with Flask + Hamlish
Hello World (beginners) on Django
Until Hello World with Flask + uWSGI + Nginx @ Sakura's VPS (CentOS 6.6)
Hello World in Flask [Appropriate memo]
How to build Hello, World on #Nix
Hello world
Flask tutorial (from installation to hello world)
[Linux] When "| (pipe)" cannot be hit on CentOS7
Hello World with nginx + uwsgi + python on EC2
Pymacs hello world
Notes on Flask
cython hello world
Install Apache Tomcat 9 on Ubuntu 19.10 Eoan Ermine Hello World