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,路由配的不仔細

按照這個寫法,我們匹配的路由應該為"http://127.0.0.1:5000/resource/vender/".

但是接口里

我們卻訪問的這個,導致發生錯誤,所以以后斜杠一定要注意

也可以在寫路由時,加上一個參數strict_slashes=False,這個匹配時,就會對末尾的/不嚴格區分,有無均能匹配成功

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM