Flask / uWSGI抛出错误无法加载app 0(mountpoint ='')

时间:2015-12-10 20:20:05

标签: python uwsgi

我试图运行(仅用于测试目的):

uwsgi --socket 0.0.0.0:8000 --protocol=http -w wsgi_prod
来自某个目录的

home.py
home.pyc
wsgi_prod.py
wsgi_prod.pyc

我的wsgi_prod.py有:

from home import app

if __name__ == "__main__":
    app.run()

home.py有:

from flask import Flask, render_template
from jinja2 import Template

app = Flask(__name__, static_folder='static')

@app.route('/')
def home():
    print('Hello world')
if __name__ == '__main__':
    app.run(host='0.0.0.0')

当我运行它时,它会抛出:

unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) 

我做错了什么?为什么它看不到我的应用程序?

谢谢!

1 个答案:

答案 0 :(得分:5)

嗯,我希望有一天能帮助别人。 Digital Ocean提供了一篇很棒的文章来设置你的flask / uwsgi,但是为此提供了错误的命令。

请改用:

uwsgi --socket 0.0.0.0:8000 --protocol=http -w wsgi_prod:app

并使用此link