第七章示例程序say hello配置时,view模块提示AssertionError: View function mapping is overwriting an existing endpoint function: index

就在这模块会提示AssertionError: View function mapping is overwriting an existing endpoint function: index,网上寻找的解决方法也不能解决,整个项目只有一个index函数,同时想问一下怎样使用pycharm运行这个项目

AssertionError: View function mapping is overwriting an existing endpoint function: index

视图路由重复注册了,需要提供更多信息才能继续判断。

视图路由重复注册报错示例,注意两个视图函数名称都是hello

>>> from flask import Flask
>>> app = Flask('app')
>>> @app.route('/hello1')
def hello():pass

>>> @app.route('/hello2')
def hello():pass

Traceback (most recent call last):
  File "<pyshell#7>", line 1, in <module>
    @app.route('/hello2')
  File "C:\Python36\lib\site-packages\flask\app.py", line 1250, in decorator
    self.add_url_rule(rule, endpoint, f, **options)
  File "C:\Python36\lib\site-packages\flask\app.py", line 66, in wrapper_func
    return f(self, *args, **kwargs)
  File "C:\Python36\lib\site-packages\flask\app.py", line 1221, in add_url_rule
    'existing endpoint function: %s' % endpoint)
AssertionError: View function mapping is overwriting an existing endpoint function: hello
>>> 

你好,完整的报错信息如下

Traceback (most recent call last):
File “D:/FinalDesign/demo2/views.py”, line 15, in
@app.route(’/’, methods=[‘GET’, ‘POST’])
File “D:\Anaconda\envs\tensorflow\lib\site-packages\flask\app.py”, line 1250, in decorator
self.add_url_rule(rule, endpoint, f, **options)
File “D:\Anaconda\envs\tensorflow\lib\site-packages\flask\app.py”, line 66, in wrapper_func
return f(self, *args, **kwargs)
File “D:\Anaconda\envs\tensorflow\lib\site-packages\flask\app.py”, line 1221, in add_url_rule
‘existing endpoint function: %s’ % endpoint)
AssertionError: View function mapping is overwriting an existing endpoint function: index

第七章的sayhello项目是一个SPA项目,所以项目里只有一个index路由函数,我并没有找到其他的index函数,请问这样的状况是什么呢

尝试了几个网上的方法也没法解决,项目运行不起来。。

加QQ群吧,贴一下你的代码,大家帮你找茬。