File size: 646 Bytes
4585d4c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import streamlit as st




def initApp():
    # Import here to avoid top-level circular import issues with Streamlit
    from app import App

    # If an App instance exists in session, reuse it. Otherwise create a fresh one.
    if 'app' not in st.session_state:
        st.session_state.app = App()
    else:
        # Ensure the session-backed fields are synchronized into the live App
        try:
            st.session_state.app.load_from_session()
        except Exception:
            # If loading fails, recreate a fresh App to avoid stale state
            st.session_state.app = App()

    return st.session_state.app


app = initApp()