OctopusLian / learn-python-flask

参考Flask官方文档的代码实践仓库
0 stars 0 forks source link

Error: Could not locate a Flask application. You did not provide the "FLASK_APP" environment variable, and a "wsgi.py" or "app.py" module was not found in the current directory. #1

Open OctopusLian opened 3 years ago

OctopusLian commented 3 years ago

windows下执行

> set FLASK_APP=flaskr
> set FLASK_ENV=development
> flask run

出错:

Error: Could not locate a Flask application. You did not provide the "FLASK_APP" environment variable, and a 
"wsgi.py" or "app.py" module was not found in the current directory.
OctopusLian commented 3 years ago

如果是在 Windows 下,那么导出环境变量的语法取决于使用的是哪种命令行解释器。 在 Command Prompt 下:

C:\path\to\app>set FLASK_APP=hello.py

在 PowerShell 下:

PS C:\path\to\app> $env:FLASK_APP = "hello.py"

还可以使用 python -m flask:

$ export FLASK_APP=hello.py $ python -m flask run