《Flask Web开发》学习笔记之bug--(2)【AssertionError: View function mapping is overwriting an existing endpoi】
来源:互联网 发布:苹果6当前网络不可用 编辑:程序博客网 时间:2024/06/11 05:45
# hello.pyfrom datetime import datetimefrom flask import Flask, render_templatefrom flask_script import Managerfrom flask_bootstrap import Bootstrapfrom flask_moment import Momentapp = Flask(__name__)manager = Manager(app)bootstrap = Bootstrap(app)moment = Moment(app)@app.errorhandler(404)def page_not_found(e):return render_template('404.html'), 404@app.errorhandler(500)def internal_server_error(e):return render_template('500.html'), 500@app.route('/')def index():return render_template('index.html', current_time=datetime.utnow())@app.route('/')def index():return render_template('index.html')@app.route('/user/<name>')def user(name):return render_template('user.html', name=name)if __name__ == '__main__':manager.run()
$ python3 hello.py runserver --host 0.0.0.0Traceback (most recent call last): File "hello.py", line 26, in <module> @app.route('/') File "/home/henry/.local/lib/python3.5/site-packages/flask/app.py", line 1080, in decorator self.add_url_rule(rule, endpoint, f, **options) File "/home/henry/.local/lib/python3.5/site-packages/flask/app.py", line 64, in wrapper_func return f(self, *args, **kwargs) File "/home/henry/.local/lib/python3.5/site-packages/flask/app.py", line 1051, in add_url_rule 'existing endpoint function: %s' % endpoint)AssertionError: View function mapping is overwriting an existing endpoint function: index
定位:
hello.py的@app.route('/')装饰器重写了index函数
解决办法:
删掉一个多余的index()函数。
阅读全文
0 0
- 《Flask Web开发》学习笔记之bug--(2)【AssertionError: View function mapping is overwriting an existing endpoi】
- 《Flask Web开发》学习笔记之bug--(3)【ExtDeprecationWarning: Importing flask.ext.wtf is deprecated, use flask_】
- 《Flask Web开发》学习笔记之bug--(6)【TypeError: __init__() got an unexpected keyword argument 'method'】
- 《Flask Web开发》学习笔记之bug--(1)【404 Not Found】
- 《Flask Web开发》学习笔记之bug--(5)【jinja2.exceptions.TemplateSyntaxError: Encountered unknown tag 'endlock'】
- 《Flask Web开发》学习笔记之bug--(7)【ImportError: cannot import name 'db'】
- 《Flask Web开发》学习笔记之bug--(8)【ImportError: No module named flask_mail】
- 《Flask Web开发》学习笔记之bug--(9)【jinja2.exceptions.TemplateSyntaxError: unexpected '%'】
- 《Flask Web开发》学习笔记之bug--(4)【AttributeError: type object 'datetime.datetime' has no attribute 'utnow'】
- Flask Web 开发学习笔记(一)
- Flask之旅《Flask Web开发:基于Python的Web应用开发实战》学习笔记
- FSADeprecationWarning(关键词:Web开发/Flask/bug)
- Flask web学习笔记2
- ValueError: View function did not return a response(关键词:Web开发/bug)
- Flask Web开发学习之“HelloWorld”
- 基于Python的Flask Web开发 笔记 (2)
- Flask Web 开发学习稿(一)
- Flask Web 开发学习稿(二)
- nod1264 线段相交(计算几何)
- 如何有效的编写软件测试用例
- 祛斑小提示
- Sqlserver小数保留指定位数
- 【DP】简单【121. Best Time to Buy and Sell Stock】【303. Range Sum Query
- 《Flask Web开发》学习笔记之bug--(2)【AssertionError: View function mapping is overwriting an existing endpoi】
- requestLayout、invalidate与postInvalidate的区别与使用场景分析
- Logback相关知识汇总
- 关于python元组数据截取问题的记录
- openlayers,创建map
- G
- 使用jdbcTemplate从数据库中删除收藏文书,并将执行结果返回前台
- iperf命令说明
- vue初学笔记