flask用uwsgi启动部署后报500

下面是遇到的报错信息

unable to find "application" callable in file /opt/applications/application/main.py
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 master process (pid: 763)
spawned uWSGI worker 1 (pid: 767, cores: 2)
spawned uWSGI http 1 (pid: 769)

no python application found, check your startup logs for errors

原因是:

uWSGI不能加载__main__下的应用程序,需要在flask主程序文件中去掉

if __name__ == '__main__':

修改启动程序的代码块


版权声明:本文为yangjiajia123456原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。