AssertionError: View function mapping is overwriting an existing endpoint function: insertCase
首先,理解这个错误是什么意思,以及出现的原因:
使用Flask定义URL的时候,如果出现"AssertionError: View function mapping is overwriting an existing endpoint function"这个异常信息,就说明定义了多个同名的视图函数,只需要改成不同的函数名即可。
这是为什么呢?
原来flask中url跟视图函数并不是直接对应的,而是有一个中间者-endpoint。
三者之间的关系是这样的:
```
url---->endpoint---->view_function
```
它们是一对一的关系,在注册add_url_rule的时候,如果不指定endpoint,那么endpoint就会默认为函数名字,如果同一个endpoint于多个url注册的话,就会发生冲突,从而抛出异常。
我出错误的原因:
在项目的初始文件 init中
我导入了views模块,这相当于会执行views中的代码(变量定义,视图函数等)
然后我在views模块想要调试的时候,就相当于再次定义一样的变量,视图函数,所以就会出现上面的错误,即定义了多个同名的视图函数
解决办法:
这里把init中这句代码注释掉就可以了

再次单独运行views文件即可正常启动服务了

https://www.jianshu.com/p/3201a8f4dc56
AssertionError: View function mapping is overwriting an existing endpoint function: insertCase的更多相关文章
- 【Flask】报错解决方法:AssertionError: View function mapping is overwriting an existing endpoint function: main.user
运行Flask时出现了一个错误, AssertionError: View function mapping is overwriting an existing endpoint function: ...
- AssertionError: View function mapping is overwriting an existing endpoint function: admin.main
刚才给views.py文件添加了一个路由地址: @admin_view.route('/test', methods=["get", "post"]) @log ...
- "AssertionError: View function mapping is overwriting an existing endpoint function"如何解决
使用Flask定义URL的时候,如果出现"AssertionError: View function mapping is overwriting an existing endpoint ...
- Flask之endpoint错误View function mapping is overwriting an existing endpoint function: ***
最近在学习Flask, 其中遇到了一个错误, 发现这个问题和Flask, 路由有关系, 所以就记了下来 错误代码: from flask import Flask, render_template, ...
- STM32F4 Alternate function mapping
#define GPIO_AF0_MCO // MCO (MCO1 and MCO2) Alternate Function mapping #define GPIO_AF0_RTC_50Hz // ...
- Function Programming - First Class(一等公民function)
引用外界一等公民的定义:"在JavaScript世界中函数却是一等公民,它不仅拥有一切传统函数的使用方式(声明和调用),而且可以做到像简单值一样赋值.传参.返回,这样的函数也称之为第一级函数 ...
- javax.websocket.DeploymentException: Multiple Endpoints may not be deployed to the same path [/websocket/{sid}] : existing endpoint was class com.sanyi.qibaobusiness.framework.webSocket.WebSocketServe
报错: javax.websocket.DeploymentException: Multiple Endpoints may not be deployed to the same path [/w ...
- 一个基础的问题 多个$(function(){})里面的函数 为什么在下一个$(function(){})里没法执行。
先看下例子 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <tit ...
- Java JVM、JNI、Native Function Interface、Create New Process Native Function API Analysis
目录 . JAVA JVM . Java JNI: Java Native Interface . Java Create New Process Native Function API Analys ...
随机推荐
- pureftp安装
1.下载 #cd /usr/local/src #wget http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.36.t ...
- 更改导航栏的背景和文字Color
更改导航栏的背景和文字Color方法一: [objc] view plaincopy//set NavigationBar 背景颜色&title 颜色 [self.navigationCon ...
- mailto - 简单多媒体邮件发送程序
SYNOPSIS mailto [-a] [-c] [-s] [recipient name(s)] DESCRIPTION mailto 程序是一个用于发送MIME格式的多媒体邮件(MIME格式是 ...
- flockfile, ftrylockfile, funlockfile - 为标准输入输出锁定文件 FILE
SYNOPSIS 总览 #include <stdio.h> void flockfile(FILE *filehandle); int ftrylockfile(FILE *fileha ...
- CentOS7编译安装MySQL8.0
1.下载mysql8.0.16源码包和cmake源码包 cd /usr/local/srcwget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-b ...
- mybatis返回自增主键问题踩坑
1 <insert id="insert" keyProperty="id" useGeneratedKeys="true" par ...
- 非父子组件通过事件传值-vue
1.创建中央事件总线:额外的 new Vue()2.$emit 触发事件3.$on 监听事件 在使用组件的文件中: <template> <div> <x-test :b ...
- python-语言播报
利用系统自带模块: 在cmd中 python -m pip install pypiwin32 安装win32com模块 import win32com.client sp=win32co ...
- 解决GitHub加载不出图片问题
解决方法: 复制 raw.githubusercontent.com 去 https://www.ipaddress.com 搜索,把给出的IP地址存储到 host 文件中: 如 199.232.28 ...
- LTM_本地流量管理(二)
会话保持 首先要熟悉两个概念:连接connect和会话session 连接:在四层负载均衡中,连接是最小元素. l 源端口:客户端随机产生的端口. l 源地址:发起请求的源IP地址. l 目的端 ...