[英]How to run a flask program when debug = True
I am a beginner to flask and I have been trying to run a simple program.我是烧瓶的初学者,我一直在尝试运行一个简单的程序。 For some reasons I am using THONNY as I just could not get flask running in a virtualenv even after so many tries.由于某些原因,我使用 THONNY,因为即使经过这么多次尝试,我也无法在 virtualenv 中运行烧瓶。 In thonny it worked without a virtualenv在 thonny 中,它在没有 virtualenv 的情况下工作
Coming at the point I wrote a simple code在这一点上我写了一个简单的代码
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return 'Flask webapp'
if __name__ == "__main__":
app.run(debug = True)
When I did not pass debug = True
the app worked and was started on a localhost but after adding debug it gave me the following error当我没有通过debug = True
应用程序工作并在本地主机上启动但添加调试后它给了我以下错误
* Serving Flask app 'app' (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: on
* Restarting with stat
C:\Users\Workstation\AppData\Local\Programs\Thonny\python.exe: No module named thonny.plugins.cpython.app
What could be a possible fix to it?有什么可能的解决方法? Should I continue using thonny for flask?我应该继续将 thonny 用于烧瓶吗?
Install Flask by running (pip3 if using Python 3 and using linux) pip install flask - in a terminal.通过在终端中运行(如果使用 Python 3 和使用 linux 则为 pip3)pip install flask - 来安装 Flask。
When you install flask, run your code in a terminal by typing (py if you are using windows) py filename.py安装 Flask 时,在终端中输入(如果您使用的是 Windows,则为 py) py filename.py
(python or python3 if you are using linux or mac) python filename.py (python 或 python3,如果您使用的是 linux 或 mac) python filename.py
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.