1

I have written a simple page to be displayed through the link "http://127.0.0.1:5000/". When I first created it is was set to display "Hello World", but now that I have tested to see if it changed the contents of the page if I were to change the code to display "Hello!!!, with three exclamation marks (mind you)".

But it doesn't update it. I have saved the new document and assured it is running on the same port, but it just doesn't update the contents of the webpage.

from flask import Flask
app = Flask(__name__)
@app.route("/")
def index():
    return "hello, World!!!, with three exclamation marks (mind you)"

CEOV
  • 13
  • 1
  • 3
  • 1
    Possible duplicate of [Auto reloading python Flask app upon code changes](https://stackoverflow.com/questions/16344756/auto-reloading-python-flask-app-upon-code-changes) – sytech Jul 14 '19 at 04:44
  • Flush web browser. – maslak Jul 14 '19 at 20:10

1 Answers1

1

Two things.

1. You must reload the webpage each time you change the content

2. You must re-run your flask code if the value inside the return has changed.

Calder White
  • 1,287
  • 9
  • 21
  • I have done both of those things, and it still doesn't display something different – CEOV Jul 14 '19 at 16:47
  • I have tried to quit (ctrl + c) and then run "python -m flask run" again, but when I reload the page, it doesn't change the return value. – CEOV Jul 14 '19 at 16:51
  • Try running `python app.py`, or whatever filename of your python file instead of the `python -m flask run`. – Calder White Jul 14 '19 at 18:15
  • I'll try as soon as I can. – CEOV Jul 14 '19 at 20:45
  • And, what's the difference between using "python app.py" and "python3 app.py"? – CEOV Jul 14 '19 at 20:47
  • @CEOV The difference is the version of python. Conventionally, "python" is version 2 or lower. "python3" is version 3. – Calder White Jul 15 '19 at 00:23
  • I just tried it, both with python and python3, but neither of them seems to work – CEOV Jul 15 '19 at 00:53
  • @CEOV did you try it with the specifc file? I was talking less about version, and more about specifying the particular file you wish to run. This is because you mentioned you ran `python -m flask run` which relies on environment variables to choose which python file to execute. – Calder White Jul 15 '19 at 01:43
  • You know what, I might just delete the directory and try it on another, same code just different files. – CEOV Jul 15 '19 at 01:57
  • Thank you so much man. It works now that I have tried to run it on another directory – CEOV Jul 15 '19 at 04:57
  • @CEOV sweet. Could you mark my answer correct if it helped you? Thanks ;) – Calder White Jul 15 '19 at 12:30