设置FLASK

编程入门 行业动态 更新时间:2024-10-27 18:31:48
本文介绍了设置FLASK_DEBUG = 1在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

本文发布于:2023-07-20 17:41:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1169640.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:FLASK

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!