set FLASK_DEBUG=1 not working on Powershell

Viewed 8630

I'm building a Flask application and my file "helloworld.py" is:

from flask import Flask
app = Flask(__name__)

@app.route('/home')
def hello_world():
    return 'Home!'

@app.route('/about')
def about_us():
    return 'aboutus!'

My Flask code after activating venv:

set FLASK_DEBUG=1
flask run

Changes made to my "helloworld.py" file doesn't get automatically updated. I still have to restart it manually as I change anything in the code.

There is no error thrown but the changes simply don't reflect in the browser. Why is the debug mode not working, can someone help me out?

4 Answers

If your OS is Windows, you can make use of VSC terminal an run the same code

set FLASK_DEBUG=1
flask run

Make sure you are only making changes inside py file, not in the terminal, otherwise it won't work.

if you are on Linux, use 'export' command instead of 'set' and yes, its not working on power shell use CMD, but even this did not work properly.so I had to use embedded terminal. but the good thing is that you can use normal CMD(not PowerShell) as embedded terminal. so the solution is, do not use PowerShell.

Solution to set FLASK_DEBUG=1 not working is,

Note- terminal->Use cmd terminal in VSCODE and NOT powershell

do the required on cmd terminal in vscode which is

    set FLASK_APP=app.py
    set FLASK_DEBUG=1
    flask run
Related