博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Flask and uWSGI - unable to load app 0 (mountpoint='') (callable not found or import error)
阅读量:7041 次
发布时间:2019-06-28

本文共 1579 字,大约阅读时间需要 5 分钟。

Here is my directory structure:

-/path/to/folder/run.py -|app -|__init__.py -|views.py -|templates -|static

Contents of /path/to/folder/run.py

if __name__ == '__main__': from app import app #app.run(debug = True) app.run()

Contents of /path/to/folder/app/__init__.py

import osfrom flask import Flask from flask.ext.sqlalchemy import SQLAlchemy from flask.ext.login import LoginManager #from flaskext.babel import Babel from config import basedir app = Flask(__name__) app.config.from_object('config') #app.config.from_pyfile('babel.cfg') db = SQLAlchemy(app) login_manager = LoginManager() login_manager.setup_app(app) login_manager.login_view = 'login' login_manager.login_message = u"Please log in to access this page." from app import views *** Operational MODE: preforking *** unable to find "application" callable in file /path/to/folder/run.py 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 (pid: 26972, cores: 1) spawned uWSGI worker 2 (pid: 26973, cores: 1)
 

2 Answers

13accepted

uWSGI doesn't load your app as __main__, so it never will find the app (since that only gets loaded when the app is run as name __main__). Thus, you need to import it outside of the if __name__ == "__main__": block.

Really simple change:

from app import appif __name__ == "__main__": app.run()

Now you can run the app directly with python run.py or run it through uWSGI the way you have i

转载地址:http://cyxal.baihongyu.com/

你可能感兴趣的文章
制作liveusb实现ubuntserver12全自动无人职守安装
查看>>
centos7的fstab要小心
查看>>
Windows phone8 基础篇(三)常用控件(二)
查看>>
架构师速成4.8-幼儿园书单资料推荐
查看>>
MySQL-Proxy实现读写分离部署文档
查看>>
For Update
查看>>
Hyper-V 之03 创建iSCSI存储和故障转移群集
查看>>
如何成为一名架构师?
查看>>
我的友情链接
查看>>
nfs failed, reason given by server: Permission denied的离奇解决
查看>>
2018 1.21测试
查看>>
DFS与BFS对比
查看>>
dedeCMS php语法在模版中的应用
查看>>
sublime 安装ctag 实现函数跳转
查看>>
sshd问题:A protocol error occurred. Change of username or service not allowed
查看>>
jQuery开发者眼中的AngularJS
查看>>
【DAY9】 关于多线程熊吃蜜Demo1的作业实验
查看>>
Python实现多属性排序
查看>>
nginx 访问日志分析
查看>>
RabbitMQ之消息确认机制(事务+Confirm)
查看>>