最新消息:20190717 VPS服务器:Vultr新加坡,WordPress主题:大前端D8,统一介绍入口:关于

[已解决]CentOS中运行Flask出错:Error Could not locate Flask application You did not provide the FLASK_APP environment variable

CentOS crifan 3433浏览 0评论

之前已经:

[记录]CentOS中运行Flask服务器

后来断开连接后,再去连接上服务器,

进入虚拟环境:

[已解决]CentOS中退出了virtualenv之后如何再进入之前virtualenv

再去运行flask,结果出错:

(SIPEvents)  SIPEvents flask run –host=0.0.0.0
Usage: flask run [OPTIONS]
Error: Could not locate Flask application. You did not provide the FLASK_APP environment variable.
For more information see http://flask.pocoo.org/docs/latest/quickstart/
(SIPEvents)  SIPEvents

搜:

flask run Error: Could not locate Flask application. You did not provide the FLASK_APP environment variable.

参考:

python – Error while running Minimal Flask application – Stack Overflow

Could not locate Flask application. You did not provide the FLASK_APP environment variable.

后来才注意到,之前的帖子里:

[记录]CentOS中运行Flask服务器

是先要去设置FLASK_APP这个环境变量的:

export FLASK_APP=hello.py

然后才能运行

而此处的警告,也是提示要去设置FLASK_APP

所以就先去设置,再运行:

(SIPEvents)  SIPEvents export FLASK_APP=hello.py
(SIPEvents)  SIPEvents export FLASK_APP=hello.py
(SIPEvents)  SIPEvents flask run –host=0.0.0.0 
(SIPEvents)  SIPEvents export FLASK_DEBUG=1
(SIPEvents)  SIPEvents flask run –host=0.0.0.0
 * Serving Flask app "hello"
 * Forcing debug mode on
 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
 * Restarting with stat
 * Debugger is active!
 * Debugger pin code: 353-795-063

转载请注明:在路上 » [已解决]CentOS中运行Flask出错:Error Could not locate Flask application You did not provide the FLASK_APP environment variable

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
59 queries in 0.108 seconds, using 18.83MB memory