设置FLASK_DEBUG = 1在Powershell上不起作用 [英] set FLASK_DEBUG=1 not working on Powershell
问题描述
我正在构建Flask应用程序,并且我的文件" helloworld.py "是:
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!'
激活venv后的我的Flask代码:
My Flask code after activating venv:
set FLASK_DEBUG=1
flask run
对我的" helloworld.py "文件所做的更改不会自动更新.更改代码中的任何内容后,我仍然必须手动重新启动它.
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?
推荐答案
PowerShell中用于设置环境变量的语法不同.对于Flask 1.0及更高版本,您应该改为设置FLASK_ENV
.
The syntax for setting environment variables is different in PowerShell. And for Flask 1.0 and higher, you should set FLASK_ENV
instead.
$env:FLASK_APP = "helloworld.py"
$env:FLASK_ENV = "development"
flask run
这篇关于设置FLASK_DEBUG = 1在Powershell上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!