fabiogra
commited on
Commit
·
de58ad9
1
Parent(s):
78dd18a
fix: error session_state has no attribute 'page'
Browse files- app/header.py +6 -3
app/header.py
CHANGED
|
@@ -11,6 +11,8 @@ logging.basicConfig(
|
|
| 11 |
datefmt="%Y-%m-%d %H:%M:%S",
|
| 12 |
)
|
| 13 |
|
|
|
|
|
|
|
| 14 |
|
| 15 |
def header(logo_and_title=True):
|
| 16 |
if "first_run" not in st.session_state:
|
|
@@ -31,7 +33,7 @@ def header(logo_and_title=True):
|
|
| 31 |
if "search_results" not in st.session_state:
|
| 32 |
st.session_state.search_results = []
|
| 33 |
if "page" not in st.session_state:
|
| 34 |
-
switch_page(
|
| 35 |
|
| 36 |
st.set_page_config(
|
| 37 |
page_title="Moseca - Music Separation and Karaoke - Free and Open Source alternative to lalal.ai, splitter.ai or media.io vocal remover.",
|
|
@@ -42,17 +44,18 @@ def header(logo_and_title=True):
|
|
| 42 |
st.markdown(CSS, unsafe_allow_html=True)
|
| 43 |
|
| 44 |
options = ["Separate", "Karaoke", "About"]
|
|
|
|
| 45 |
page = option_menu(
|
| 46 |
menu_title=None,
|
| 47 |
options=options,
|
| 48 |
# bootrap icons
|
| 49 |
icons=["play-btn-fill", "file-earmark-music", "info-circle"],
|
| 50 |
-
default_index=options.index(st.session_state.page),
|
| 51 |
orientation="horizontal",
|
| 52 |
styles={"nav-link": {"padding-left": "1.5rem", "padding-right": "1.5rem"}},
|
| 53 |
key="",
|
| 54 |
)
|
| 55 |
-
if page != st.session_state.page:
|
| 56 |
switch_page(page)
|
| 57 |
|
| 58 |
if logo_and_title:
|
|
|
|
| 11 |
datefmt="%Y-%m-%d %H:%M:%S",
|
| 12 |
)
|
| 13 |
|
| 14 |
+
DEFAULT_PAGE = "Separate"
|
| 15 |
+
|
| 16 |
|
| 17 |
def header(logo_and_title=True):
|
| 18 |
if "first_run" not in st.session_state:
|
|
|
|
| 33 |
if "search_results" not in st.session_state:
|
| 34 |
st.session_state.search_results = []
|
| 35 |
if "page" not in st.session_state:
|
| 36 |
+
switch_page(DEFAULT_PAGE)
|
| 37 |
|
| 38 |
st.set_page_config(
|
| 39 |
page_title="Moseca - Music Separation and Karaoke - Free and Open Source alternative to lalal.ai, splitter.ai or media.io vocal remover.",
|
|
|
|
| 44 |
st.markdown(CSS, unsafe_allow_html=True)
|
| 45 |
|
| 46 |
options = ["Separate", "Karaoke", "About"]
|
| 47 |
+
|
| 48 |
page = option_menu(
|
| 49 |
menu_title=None,
|
| 50 |
options=options,
|
| 51 |
# bootrap icons
|
| 52 |
icons=["play-btn-fill", "file-earmark-music", "info-circle"],
|
| 53 |
+
default_index=options.index(st.session_state.get("page", DEFAULT_PAGE)),
|
| 54 |
orientation="horizontal",
|
| 55 |
styles={"nav-link": {"padding-left": "1.5rem", "padding-right": "1.5rem"}},
|
| 56 |
key="",
|
| 57 |
)
|
| 58 |
+
if page != st.session_state.get("page", DEFAULT_PAGE):
|
| 59 |
switch_page(page)
|
| 60 |
|
| 61 |
if logo_and_title:
|