日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Flask框架后端开发常见错误处理(2018/11/14)

發布時間:2024/9/5 编程问答 52 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Flask框架后端开发常见错误处理(2018/11/14) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Flask常見錯誤與解決方法(By Wdx)

1.ValueError: urls must start with a leading slash

這個錯誤原因可能發生在所有路由相關地方,少加了一個'/'造成的。

2.ImportError: cannot import name 'db'

這個錯誤原因是產生了循環導入問題,修改import的位置即可

3.AssertionError: View function mapping is overwriting an existing endpoint function: manager.check_permission

這個錯誤原因是自定義的裝飾器中沒有使用functools模塊下的wraps(func)修飾wrapper (func)

4.socket.gaierror: [Errno -2] Name or service not known

這個錯誤原因是當發送郵件等事務發生時,虛擬機沒聯網

5.The method is not allowed for the requested URL.

這個錯誤原因是路由書寫時候,前一個路由沒有寫methods=['POST','GET']

6.AttributeError: 'SQLAlchemy' object has no attribute 'commit'

這個錯誤原因是db.session.commit(),可能忘記寫session

7.RuntimeError: No application found. Either work inside a view function or push an application context.

這個錯誤原因是應該寫進視圖模塊中的代碼約束,寫到了表單模塊中

8.TypeError: redirect() got an unexpected keyword argument 'id'

這個錯誤原因可能不僅僅是重定向傳錯參數,還有可能只寫了redirect,忘記寫url_for

9.ERROR [root] Error: Can't locate revision identified by '8a92edbd0e8e'

這個問題是數據庫中表alembic_version版本過低,直接刪除

?

?

轉載于:https://www.cnblogs.com/wdx520/p/9959658.html

總結

以上是生活随笔為你收集整理的Flask框架后端开发常见错误处理(2018/11/14)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。