Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import pandas as pd
|
|
3 |
from processor import DataProcessor
|
4 |
from llm_handler import DDoSInference
|
5 |
|
|
|
6 |
class DDoSResistanceHelper:
|
7 |
def __init__(self):
|
8 |
# Set up Streamlit page configuration
|
@@ -46,17 +47,27 @@ class DDoSResistanceHelper:
|
|
46 |
|
47 |
def setup_session_state(self):
|
48 |
"""Initialize Streamlit session state variables."""
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
for key in session_keys:
|
52 |
if key not in st.session_state:
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
55 |
|
56 |
def apply_theme(self):
|
57 |
"""Apply selected theme to Streamlit app."""
|
58 |
-
theme_name = st.session_state.get('selected_theme', 'Light')
|
59 |
-
theme = self.themes[
|
60 |
st.markdown(f"""
|
61 |
<style>
|
62 |
.stApp {{
|
@@ -68,8 +79,10 @@ class DDoSResistanceHelper:
|
|
68 |
|
69 |
def render_theme_selector(self):
|
70 |
"""Render theme selection icons on the top-right corner."""
|
71 |
-
st.
|
72 |
-
|
|
|
|
|
73 |
if st.button("🌞 Light", key="light_theme"):
|
74 |
st.session_state.selected_theme = 'Light'
|
75 |
self.apply_theme()
|
@@ -134,6 +147,7 @@ class DDoSResistanceHelper:
|
|
134 |
self.render_analysis_interface()
|
135 |
self.render_chat_interface()
|
136 |
|
|
|
137 |
if __name__ == "__main__":
|
138 |
app = DDoSResistanceHelper()
|
139 |
app.main()
|
|
|
3 |
from processor import DataProcessor
|
4 |
from llm_handler import DDoSInference
|
5 |
|
6 |
+
|
7 |
class DDoSResistanceHelper:
|
8 |
def __init__(self):
|
9 |
# Set up Streamlit page configuration
|
|
|
47 |
|
48 |
def setup_session_state(self):
|
49 |
"""Initialize Streamlit session state variables."""
|
50 |
+
session_keys = [
|
51 |
+
'chat_history',
|
52 |
+
'current_file',
|
53 |
+
'analysis_complete',
|
54 |
+
'selected_theme',
|
55 |
+
'preview_data'
|
56 |
+
]
|
57 |
+
|
58 |
for key in session_keys:
|
59 |
if key not in st.session_state:
|
60 |
+
if key == 'chat_history':
|
61 |
+
st.session_state[key] = []
|
62 |
+
elif key == 'selected_theme':
|
63 |
+
st.session_state[key] = 'Light' # Default theme
|
64 |
+
else:
|
65 |
+
st.session_state[key] = None
|
66 |
|
67 |
def apply_theme(self):
|
68 |
"""Apply selected theme to Streamlit app."""
|
69 |
+
theme_name = st.session_state.get('selected_theme', 'Light') # Default to 'Light' if not set
|
70 |
+
theme = self.themes.get(theme_name, self.themes['Light']) # Fallback to 'Light' if theme invalid
|
71 |
st.markdown(f"""
|
72 |
<style>
|
73 |
.stApp {{
|
|
|
79 |
|
80 |
def render_theme_selector(self):
|
81 |
"""Render theme selection icons on the top-right corner."""
|
82 |
+
st.write(
|
83 |
+
'<div style="position: absolute; top: 15px; right: 15px;">',
|
84 |
+
unsafe_allow_html=True
|
85 |
+
)
|
86 |
if st.button("🌞 Light", key="light_theme"):
|
87 |
st.session_state.selected_theme = 'Light'
|
88 |
self.apply_theme()
|
|
|
147 |
self.render_analysis_interface()
|
148 |
self.render_chat_interface()
|
149 |
|
150 |
+
|
151 |
if __name__ == "__main__":
|
152 |
app = DDoSResistanceHelper()
|
153 |
app.main()
|