![](/img/trans.png)
[英]unable to load app 0 (mountpoint='') - Flask app with uwsgi
[英]Why my python file returns unable to load app in uwsgi flask?
我已经阅读了以下与uwsgi
相关的问题,有趣的是,到目前为止没有任何帮助:
似乎我需要将 app 作为application
导入,因为uWSGI
试图找到应用程序变量。
from tf_api import create_app as application
if __name__ == "__main__":
application = application()
application.run()
else:
print("---------------------->", __name__)
application = application()
当我运行以下命令时:
uwsgi --socket 0.0.0.0:80 --protocol=tcp -w wsgi:app
它转到else
部分并输出:
----------------------> wsgi
2020-02-20 14:25:22,168 [tf_core] Initialized! [testing=False]
2020-02-20 14:25:22,176 [tf_api] {"msg": "Initialized! Testing: False", "logger_name": "tf_api", "log_level": "DEBUG", "timestamp": "2020-02-20T14:25:22.176664"}
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 27143, cores: 1)
一些日志是从应用程序打印出来的,然后它打印no app loaded
!
当我将application.run(host='0.0.0.0')
放在 else 中时,似乎应用程序开始运行,但在烧瓶默认端口5000
而不是在uWSGI
:
----------------------> wsgi
2020-02-20 14:36:57,333 [tf_core] Initialized! [testing=False]
2020-02-20 14:36:57,339 [tf_api] {"msg": "Initialized! Testing: False", "logger_name": "tf_api", "log_level": "DEBUG", "timestamp": "2020-02-20T14:36:57.339723"}
* Serving Flask app "tf_api" (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
2020-02-20 14:36:57,405 [werkzeug] * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
2020-02-20 14:36:57,406 [werkzeug] * Restarting with stat
unable to load configuration from /usr/local/lib/python3.6/dist-packages/tf_api/uwsgi
但是它给出了一个与unable to load configuration from
. created_app
返回app
。 你们认为在uswgi
找不到该app
的原因是什么?
在uwsgi
命令中我使用-w wsgi:app
我不得不重命名以下代码:
application = application()
到:
app = application()
没有app.run()
,因为uWSGI
本身运行烧瓶应用程序,它是不需要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.