Flask application with Blueprints+uWSGI+nginx returning 404's (no routing?)

纵饮孤独 提交于 2019-12-24 12:44:08

问题


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()

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.

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.

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

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


回答1:


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 :

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

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 :

from flask import Blueprint


来源:https://stackoverflow.com/questions/23381947/flask-application-with-blueprintsuwsginginx-returning-404s-no-routing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!