Spaces:
Running
Running
Fix session state initialization
Browse files- advanced_scraper_ui.py +1 -16
- app.py +16 -1
advanced_scraper_ui.py
CHANGED
@@ -9,22 +9,7 @@ from datetime import datetime
|
|
9 |
from dotenv import load_dotenv
|
10 |
from enhanced_scraper import EnhancedRedditScraper
|
11 |
|
12 |
-
# Note: Page configuration
|
13 |
-
|
14 |
-
# Session state initialization
|
15 |
-
if 'results' not in st.session_state:
|
16 |
-
st.session_state.results = None
|
17 |
-
if 'scraper' not in st.session_state:
|
18 |
-
st.session_state.scraper = None
|
19 |
-
if 'search_history' not in st.session_state:
|
20 |
-
st.session_state.search_history = []
|
21 |
-
if 'filters' not in st.session_state:
|
22 |
-
st.session_state.filters = {
|
23 |
-
'min_score': 0,
|
24 |
-
'date_from': None,
|
25 |
-
'date_to': None,
|
26 |
-
'show_only_with_comments': False
|
27 |
-
}
|
28 |
|
29 |
# Functions
|
30 |
def initialize_scraper(client_id, client_secret, user_agent):
|
|
|
9 |
from dotenv import load_dotenv
|
10 |
from enhanced_scraper import EnhancedRedditScraper
|
11 |
|
12 |
+
# Note: Page configuration and session state initialization are handled in app.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
# Functions
|
15 |
def initialize_scraper(client_id, client_secret, user_agent):
|
app.py
CHANGED
@@ -58,7 +58,22 @@ except Exception as e:
|
|
58 |
# No secrets configured, will fall back to user input
|
59 |
pass
|
60 |
|
61 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
from advanced_scraper_ui import main
|
63 |
|
64 |
# Run the app
|
|
|
58 |
# No secrets configured, will fall back to user input
|
59 |
pass
|
60 |
|
61 |
+
# Initialize session state before importing main
|
62 |
+
if 'results' not in st.session_state:
|
63 |
+
st.session_state.results = None
|
64 |
+
if 'scraper' not in st.session_state:
|
65 |
+
st.session_state.scraper = None
|
66 |
+
if 'search_history' not in st.session_state:
|
67 |
+
st.session_state.search_history = []
|
68 |
+
if 'filters' not in st.session_state:
|
69 |
+
st.session_state.filters = {
|
70 |
+
'min_score': 0,
|
71 |
+
'date_from': None,
|
72 |
+
'date_to': None,
|
73 |
+
'show_only_with_comments': False
|
74 |
+
}
|
75 |
+
|
76 |
+
# Now that page config is set and session state initialized, import the main function
|
77 |
from advanced_scraper_ui import main
|
78 |
|
79 |
# Run the app
|