带有Blueprints + uWSGI + nginx返回404的Flask应用程序(没有路由?) [英] Flask application with Blueprints+uWSGI+nginx returning 404's (no routing?)

查看:182
本文介绍了带有Blueprints + uWSGI + nginx返回404的Flask应用程序(没有路由?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用nginx + uWSGI成功部署了一个最小的Flask应用程序,对此我感到很困惑.

Having successfully deployed a minimal Flask app with nginx+uWSGI, I am stumped by this.

from flask import Flask
from bsfdash.users import users
from bsfdash.dashboard import dashboard 
from bsfdash.customs import customs
from bsfdash import app 

if __name__ == '__main__':
    app.register_blueprint(users)
    app.register_blueprint(dashboard)
    app.register_blueprint(customs)

    app.run()

要确认我的nginx和uWSGI设置正确,我使用一个简单的"Hello World" Flask应用程序进行了测试,该应用程序带有@ app.route('/'),返回"Hi!"! -它按预期工作.

To confirm my nginx and uWSGI settings are correct, I tested with a simple "Hello World" Flask application with @app.route('/') that returns "Hi!" - It worked as expected.

但是,上面显示的应用程序可以使用localhost:5000上的flask网络服务器按预期工作,但通过uWSGI调用时不会路由@ dashboard.route('/')蓝图.

However, The app shown above works as expected using the flask web-server on localhost:5000 - but does not route @dashboard.route('/') blueprint when called via uWSGI.

我发现有关使用uWSGI部署包含Blueprints的模块化Flask应用程序的零信息.

I have found zero information about deploying modular Flask applications containing Blueprints with uWSGI.

为什么该应用程序可以用作Flask Web服务器,但是会因uWSGI而死机?

Why does this application work as a Flask web-server but is braindead through uWSGI?

推荐答案

能否为我们提供有关您的应用程序结构的更多信息? 我有一个工作正常的Flask应用程序,带有蓝图,它可以帮助您.

Could you give us more information about your app structure ? I have a working Flask app with Blueprints that looks like, if it can help you.

App/run.py:

App/run.py :

import sys
sys.path.append("/subone")

from iel import app, manager
from flask.ext.migrate import MigrateCommand

manager.add_command('db', MigrateCommand)

app.debug = True
manager.run()

App/subone/ __ init __ .py

App/subone/__init__.py

from flask import Flask
from flask.ext.script import Manager
from subone import models

app = Flask(__name__)
app.config.from_object('settings')

manager = Manager(app)

#Blueprints
from catalog.views import catalog
app.register_blueprint(catalog)

from login.views import login
app.register_blueprint(login,url_prefix="/login")

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

App/subone/catalog/ __ init __ .py:

App/subone/catalog/__init__.py :

from flask import Blueprint

这篇关于带有Blueprints + uWSGI + nginx返回404的Flask应用程序(没有路由?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆