首先,理解这个错误是什么意思,以及出现的原因:

使用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文件即可正常启动服务了

参考:
理解endpoint是什么:
Flask中'endpoint'(端点)的理解(译文,不错的)

https://www.jianshu.com/p/3201a8f4dc56

AssertionError: View function mapping is overwriting an existing endpoint function: insertCase的更多相关文章

  1. 【Flask】报错解决方法:AssertionError: View function mapping is overwriting an existing endpoint function: main.user

    运行Flask时出现了一个错误, AssertionError: View function mapping is overwriting an existing endpoint function: ...

  2. AssertionError: View function mapping is overwriting an existing endpoint function: admin.main

    刚才给views.py文件添加了一个路由地址: @admin_view.route('/test', methods=["get", "post"]) @log ...

  3. "AssertionError: View function mapping is overwriting an existing endpoint function"如何解决

    使用Flask定义URL的时候,如果出现"AssertionError: View function mapping is overwriting an existing endpoint ...

  4. Flask之endpoint错误View function mapping is overwriting an existing endpoint function: ***

    最近在学习Flask, 其中遇到了一个错误, 发现这个问题和Flask, 路由有关系, 所以就记了下来 错误代码: from flask import Flask, render_template, ...

  5. STM32F4 Alternate function mapping

    #define GPIO_AF0_MCO // MCO (MCO1 and MCO2) Alternate Function mapping #define GPIO_AF0_RTC_50Hz // ...

  6. Function Programming - First Class(一等公民function)

    引用外界一等公民的定义:"在JavaScript世界中函数却是一等公民,它不仅拥有一切传统函数的使用方式(声明和调用),而且可以做到像简单值一样赋值.传参.返回,这样的函数也称之为第一级函数 ...

  7. 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 ...

  8. 一个基础的问题 多个$(function(){})里面的函数 为什么在下一个$(function(){})里没法执行。

    先看下例子 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <tit ...

  9. 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 ...

随机推荐

  1. spark性能调优03-shuffle调优

    1.开启map端输出文件的合并机制 1.1 为什么要开启map端输出文件的合并机制 默认情况下,map端的每个task会为reduce端的每个task生成一个输出文件,reduce段的每个task拉取 ...

  2. J.U.C|一文搞懂AQS(转)

    提到JAVA加锁,我们通常会想到synchronized关键字或者是Java Concurrent Util(后面简称JCU)包下面的Lock,今天就来扒一扒Lock是如何实现的,比如我们可以先提出一 ...

  3. Java的volatile

    1.同步 同synchronized相比(synchronized通常称为重量级锁),volatile更轻量级 如图,如果变量没有volatile关键字,那么A线程对该变量的改变存储在内存A,B变量不 ...

  4. Codeforces Round #427 (Div. 2) - D

    题目链接:http://codeforces.com/contest/835/problem/D 题意:给定一个字符串,定义kth回文是左半部分等于右半部分,并且左半部分和右半部分都是(k-1)th回 ...

  5. PAT Advanced 1042 Shuffling Machine (20 分)(知识点:利用sstream进行转换int和string)

    Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...

  6. springboot之学习搭建

    什么是**SpringBoot?** Spring Boot 是由 Pivotal 团队提供的全新框架,其设计目的是用来简化新 Spring 应用的初始搭建以及开发过程.该框架使用了特定的方式来进行配 ...

  7. Educational Codeforces Round 68 (Rated for Div. 2) D. 1-2-K Game (博弈, sg函数,规律)

    D. 1-2-K Game time limit per test2 seconds memory limit per test256 megabytes inputstandard input ou ...

  8. Candidate Generation and LUNA16 preprocessing

    在这个kernel中,我们将讨论有助于更好地理解问题陈述和数据可视化的方法. 我还将提供有用的资源和信息的链接. 此脚本是用Python编写的. 我建议人们在桌面上安装anaconda,因为here提 ...

  9. macos升级Nodejs和Npm到最新版

    第一步,先查看本机node.js版本: node -v 第二步,清除node.js的cache: sudo npm cache clean -f 第三步,安装 n 工具,这个工具是专门用来管理node ...

  10. 原生JS 将时间转换成几秒前,几分钟前…常用于评论回复功能

    //格式化时间 留备用~ function getDateDiff(dateStr) { var publishTime = dateStr / 1000, d_seconds, d_minutes, ...