-1

I can't set my flask environment to development. It stays in production.

PS C:\Users\Admin\Desktop\webserver> Scripts\Activate.ps1
(webserver) PS C:\Users\Admin\Desktop\webserver> $env:FLASK_APP = "server.py"
(webserver) PS C:\Users\Admin\Desktop\webserver> set FLASK_ENV=development
(webserver) PS C:\Users\Admin\Desktop\webserver> flask run
* Serving Flask app 'server.py' (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off`enter code here`
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
Victor
  • 602
  • 4
  • 12
  • You do the right thing for `FLASK_APP` in PowerShell: `$env:FLASK_APP = "server.py"`. Then you do the _wrong_ thing by using the cmd syntax: `set FLASK_ENV=development`. Why are you changing? – ChrisGPT was on strike Jul 25 '21 at 00:44
  • I disagree with the selected duplicate. The issue here is about setting environment variables in PowerShell. Here's a better one: [How can I set NODE_ENV=production on Windows?](https://stackoverflow.com/q/9249830/354577) – ChrisGPT was on strike Jul 25 '21 at 00:47

1 Answers1

0

As described in Flask - Quickstart, if you want to enable the debug mode (development) with PowerShell, you need to do:

> $env:FLASK_APP = "server.py"
> $env:FLASK_ENV = "development"
> flask run

set will not be recognized by PowerShell, but CMD will.

Victor
  • 602
  • 4
  • 12