thepassionatecoder
thepassionatecoder

Reputation: 95

set FLASK_DEBUG=1 not working on Powershell

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?

Upvotes: 7

Views: 11770

Answers (3)

davidism
davidism

Reputation: 127180

The syntax for setting environment variables is different in PowerShell, use $env:.

> $env:FLASK_APP = "helloworld.py"
> $env:FLASK_DEBUG = "1"
> flask run

set is used for Windows CMD.

> set FLASK_DEBUG=1

export is used by most other shells, like Bash and Zsh, such as on Linux and MacOS.

$ export FLASK_DEBUG=1

Upvotes: 15

kushagra gaur
kushagra gaur

Reputation: 1

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.

Upvotes: -1

blackblossom
blackblossom

Reputation: 11

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.

Upvotes: -1

Related Questions