0

I am developing a login form using flask version 1.0.2 in python 3.6 and HTML in Pycharm IDE but the problem is when i edit python code in app.py file i expect the changes to take effect and when i run on default url, http://127.0.0.1:5000/, it does not show the changes in the browser.The old first output keeps being printed.

I have deleted cache and cookies and browser history from all browsers plus using CNTRL + F5 for hard refresh but the problem has persisted.

from flask import Flask
app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'men what are you doing !'

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

What could be the problem?**

5
  • Please, could you add some code so we can reproduce this problem ? Commented Jul 7, 2018 at 7:51
  • 2
    Are you restarting the server? If not then you may not have debug mode enabled which makes the server auto restart on change. If you restart the server does it show your changes? Commented Jul 7, 2018 at 10:46
  • app.run(host,port,debug=True) Commented Jul 8, 2018 at 6:04
  • the original code looks like this from flask import Flask app = Flask(name) @app.route('/') def hello_world(): return 'men what are you doing !' if name == 'main': app.run() but i edited this line of code to app.run(port=8080) and the browser updates Commented Jul 9, 2018 at 0:59
  • flask.pocoo.org/docs/1.0/server/#in-code Commented Oct 27, 2018 at 7:07

1 Answer 1

2

You will need to set enviroment variable FLASK_ENV to development (default to production) to enable debug mode:

$ export FLASK_ENV=development  # use > set ... on Windows

In debug mode, the reloader was enabled to detect file changes and reload the server.

Sign up to request clarification or add additional context in comments.

2 Comments

also it is possible to do app.debug=True, or pass it as a parameter in app.run(debug=True)
You are right, but it is not recommended to directly set the app.debug and FLASK_DEBUG since Flask 1.0. Besides, the app.run() was not recommended too since Flask 0.11, see the changlog for more information.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.