0

I have set up my first Flask project with PyCharm and this is my app.py file:

from flask import Flask

app = Flask(__name__)


@app.route('/')
def hello_world():
    return 'TEST'


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

I want to run my project in debug mode so that I do not have to restart the server every time something changes. I provide the app.run function with a debug=True parameter, but this does not seem to change the debug flag. The application does start however and I do see "TEST" on the page, but this is with the debug flag set to False.

I also tried to directly change my env variable with os.environ["FLASK_DEBUG"] = "True", but this did not affect the flag also.

Any advice?

7
  • 3
    this does not seem to work Please explain what you tried that didn't work Commented Feb 18, 2020 at 8:06
  • This debug=True has nothing to do with that.It just enables Werkzeug debugger Commented Feb 18, 2020 at 8:08
  • 3
    Are you running it using the flask command, with FLASK_ENV=development? See flask.palletsprojects.com/en/1.1.x/server/#server. Commented Feb 18, 2020 at 8:08
  • Run your flask app in command line instead of PyCharm. python3 app.py Commented Feb 18, 2020 at 8:11
  • "this is my app.js file" ??? Commented Feb 18, 2020 at 8:14

2 Answers 2

1

If you're using PyCharm, in Run/Debug config you can pass FLASK_DEBUG variable. Try to set it to "1", not to "True".

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

Comments

1

Run your flask app in command line instead of PyCharm. python3 app.py

Comments

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.