Canstralian commited on
Commit
e080f90
·
verified ·
1 Parent(s): 96820c0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -1,3 +1,4 @@
 
1
  import streamlit as st
2
  from components.dashboard import Dashboard
3
  from PurpleTeamIDS import analyze_security_log, API_TOKEN
@@ -12,15 +13,15 @@ st.set_page_config(
12
  )
13
 
14
  def main():
15
- # Get API token from environment or sidebar
16
  api_token = st.sidebar.text_input(
17
  "Hugging Face API Token",
18
- value=API_TOKEN,
19
  type="password",
20
  key="huggingface_api_token"
21
  )
22
 
23
- if api_token == "your_huggingface_api_token_here":
24
  st.warning("Please enter your Hugging Face API token in the sidebar.")
25
  st.stop()
26
 
@@ -28,8 +29,12 @@ def main():
28
  dashboard = Dashboard()
29
 
30
  # Load custom CSS
31
- with open("styles/custom.css") as f:
32
- st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
 
 
 
 
33
 
34
  # Render main content
35
  dashboard.render_main_content()
@@ -50,5 +55,4 @@ def main():
50
  st.experimental_rerun()
51
 
52
  if __name__ == "__main__":
53
- main()
54
-
 
1
+ import os
2
  import streamlit as st
3
  from components.dashboard import Dashboard
4
  from PurpleTeamIDS import analyze_security_log, API_TOKEN
 
13
  )
14
 
15
  def main():
16
+ # Get API token from environment or sidebar securely
17
  api_token = st.sidebar.text_input(
18
  "Hugging Face API Token",
19
+ value=os.getenv("HUGGING_FACE_API_TOKEN", API_TOKEN),
20
  type="password",
21
  key="huggingface_api_token"
22
  )
23
 
24
+ if not api_token or api_token == "your_huggingface_api_token_here":
25
  st.warning("Please enter your Hugging Face API token in the sidebar.")
26
  st.stop()
27
 
 
29
  dashboard = Dashboard()
30
 
31
  # Load custom CSS
32
+ css_path = "styles/custom.css"
33
+ try:
34
+ with open(css_path) as f:
35
+ st.markdown(f"<style>{f.read()}</style>", unsafe_allow_html=True)
36
+ except FileNotFoundError:
37
+ st.error(f"CSS file not found: {css_path}")
38
 
39
  # Render main content
40
  dashboard.render_main_content()
 
55
  st.experimental_rerun()
56
 
57
  if __name__ == "__main__":
58
+ main()