我想在燒瓶中保存一個全局變量,並且在閱讀了一些文檔後,我知道'flask.g'可以做我想做的事情,但在測試過程中,我發現變量'g'不能像會話一樣保存,如果我在同一個應用程序中更改頁面,變量'g'錯過它的屬性,在閱讀了一些文檔之後,我發現在以前版本的flask中,變量'g'僅在請求上下文中,但是'Starting with Flask 0.10 this is stored on the application context and no longer on the request context which means it becomes available if only the application context is bound and not yet a request.'如何在燒瓶中保存一個全局變量?
所以我想知道爲什麼變量'g'不能保存在我的應用程序的所有頁面中,如果我想保存一個可以在所有頁面中使用的全局變量,我應該怎麼做?
thx!
如果您的數據是持久性的,爲什麼不使用會話? –
這是一個硒變量,不僅僅是一些數據。 –