1
我正在關注這本名爲「燒瓶網頁開發」的書。燒瓶異常「查看功能映射覆蓋現有的端點功能」
當我創建他創建的登錄系統時,我可以在註冊我製作的藍圖時發生異常。
登錄:
C:\Python27\python.exe "C:/Users/Bo/Google Drev/Privat/HobbyProjekter/Event/manage.py"
Traceback (most recent call last):
File "C:/Users/Bo/Google Drev/Privat/HobbyProjekter/Event/manage.py", line 7, in <module>
app = create_app(os.getenv('FLASK_CONFIG') or 'default')
File "C:\Users\Bo\Google Drev\Privat\HobbyProjekter\Event\app\__init__.py", line 42, in create_app
app.register_blueprint(auth_blueprint, url_prefix='/auth')
File "C:\Python27\lib\site-packages\flask\app.py", line 62, in wrapper_func
return f(self, *args, **kwargs)
File "C:\Python27\lib\site-packages\flask\app.py", line 889, in register_blueprint
blueprint.register(self, options, first_registration)
File "C:\Python27\lib\site-packages\flask\blueprints.py", line 153, in register
deferred(state)
File "C:\Python27\lib\site-packages\flask\blueprints.py", line 172, in <lambda>
s.add_url_rule(rule, endpoint, view_func, **options))
File "C:\Python27\lib\site-packages\flask\blueprints.py", line 76, in add_url_rule
view_func, defaults=defaults, **options)
File "C:\Python27\lib\site-packages\flask\app.py", line 62, in wrapper_func
return f(self, *args, **kwargs)
File "C:\Python27\lib\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: auth.login
對於其中註冊我的藍圖中的代碼看起來是這樣的:
from .auth import auth as auth_blueprint
app.register_blueprint(auth_blueprint, url_prefix='/auth')
從我auth__init__.py代碼進口:
from flask import Blueprint
auth = Blueprint('auth', __name__)
from . import views
from flask import render_template
from . import auth
@auth.route('/login')
def login():
return render_template('auth/login.html')
在最後我的觀點我試圖註冊(只是一個片段):
@auth.route('/login', methods=['GET', 'POST'])
def login():
希望你能幫助
這有點不耐煩,但這真的有幫助!謝謝 :) – McBoman