无法解决我的烧瓶蓝图断言错误

cannot solve my flask bluprint assertion error

我正在尝试使用 Flask 中的 Bluprint 拆分我的应用程序,但我得到了 AssertionError,尽管没有同名的函数。我想如果函数名称不同,默认端点也会不同。我已经搜索过它,但我仍然无法做到这一点。请帮忙;(

这是我的controllers.py

import flask
from flask import render_template, request, redirect, url_for, flash, make_response, g, session, jsonify
from apps import app, db
from apps.models import *

from apps.controllers2 import app2

#Set application.debug=true to enable tracebacks on Beanstalk log output.
#Make sure to remove this line before deploying to production.
app.debug=True
app.register_blueprint(app2)

@app.route('/', methods=['GET', 'POST'])
@app.route('/intro', methods=['GET', 'POST'])
def hmp_showIntro():
    return render_template('intro.html')


if __name__ == '__main__':
    app.run(host='0.0.0.0')

这是独立控制器,controller2.py

from flask import render_template, request, redirect, url_for, flash, make_response, g, session, jsonify
from flask import Blueprint
from apps import app, db
app2 = Blueprint('app2', __name__)

@app2.route('/main')
def hmp_showMain():
    return render_template('main.html')

这就是我得到的

 mod_wsgi (pid=15429): Exception occurred processing WSGI script '/opt/python/current/app/apps/controllers.py'.
 Traceback (most recent call last):
   File "/opt/python/current/app/apps/controllers.py", line 17, in <module>
     @app.route('/intro', methods=['GET', 'POST'])
   File "/opt/python/run/venv/lib/python2.7/site-packages/flask/app.py", line 1013, in decorator
     self.add_url_rule(rule, endpoint, f, **options)
   File "/opt/python/run/venv/lib/python2.7/site-packages/flask/app.py", line 62, in wrapper_func
     return f(self, *args, **kwargs)
   File "/opt/python/run/venv/lib/python2.7/site-packages/flask/app.py", line 984, in add_url_rule
     'existing endpoint function: %s' % endpoint)
 AssertionError: View function mapping is overwriting an existing endpoint function: hmp_showIntro

您的应用已经有使用 hmp_showIntro 名称查看的路由。搜索该功能的项目。或者您可以双重导入 controllers.py.