I tried to build a Flask environment with VPS instead of a local environment and run Hello World, but I couldn't.
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)
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