Flask路由报错:raise FormDataRoutingRedirect(request)

  raise FormDataRoutingRedirect(request)
FormDataRoutingRedirect: A request was sent to this URL (http://127.0.0.1:5000/resource/vender) but a redirect was issued automatically by the routing system to "http://127.0.0.1:5000/resource/vender/".  The URL was defined with a trailing slash so Flask will automatically redirect to the URL with the trailing slash if it was accessed without one.  Make sure to directly send your POST-request to this URL since we can't make browsers or HTTP clients redirect with form data reliably or without user interaction.

 

又写了一个BUG,路由配的不仔细

Flask路由报错:raise FormDataRoutingRedirect(request)_第1张图片

按照这个写法,我们匹配的路由应该为"http://127.0.0.1:5000/resource/vender/".

但是接口里

我们却访问的这个,导致发生错误,所以以后斜杠一定要注意

也可以在写路由时,加上一个参数strict_slashes=False,这个匹配时,就会对末尾的/不严格区分,有无均能匹配成功

 

转载于:https://www.cnblogs.com/huchong/p/8818910.html

你可能感兴趣的:(Flask路由报错:raise FormDataRoutingRedirect(request))