mgbam commited on
Commit
5315036
·
verified ·
1 Parent(s): dd784bb

Update pages/1_Home.py

Browse files
Files changed (1) hide show
  1. pages/1_Home.py +46 -10
pages/1_Home.py CHANGED
@@ -1,23 +1,45 @@
 
1
  import streamlit as st
2
  from config.settings import settings
 
 
 
3
 
4
- st.set_page_config(page_title=f"Home - {settings.APP_TITLE}", layout="wide")
 
 
 
 
5
 
6
- if not st.session_state.get("authenticated_user"):
 
7
  st.warning("Please log in to access the application.")
 
 
 
 
 
 
 
 
 
 
 
8
  st.stop() # Stop script execution if not authenticated
9
 
10
  # --- Page Content ---
11
- st.title(f"Welcome to {settings.APP_TITLE}, {st.session_state.authenticated_user.username}!")
12
- st.markdown("""
13
- This application leverages cutting-edge AI and (simulated) quantum optimization techniques
14
- to provide insights for healthcare professionals.
 
 
 
 
15
 
16
  **Features:**
17
  - **AI-Powered Consultation:** Engage in a conversation with an AI assistant capable of understanding medical queries,
18
- looking up information from UMLS and BioPortal, and more.
19
- - **Quantum Treatment Optimizer:** (Simulated) Explore novel treatment strategies based on patient data,
20
- current treatments, and diagnosed conditions.
21
  - **Secure User Authentication:** Your data and interactions are protected.
22
  - **Reporting:** Generate PDF summaries of your consultations.
23
 
@@ -29,4 +51,18 @@ to provide insights for healthcare professionals.
29
  actual medical decision-making without verification by qualified medical professionals.*
30
  """)
31
 
32
- st.image("assets/logo.png", width=150, caption=settings.APP_TITLE)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /home/user/app/pages/1_Home.py
2
  import streamlit as st
3
  from config.settings import settings
4
+ from pathlib import Path # For checking logo path existence
5
+ from assets.logo import get_logo_path # Using the centralized logo getter
6
+ from services.logger import app_logger
7
 
8
+ # Page config should be set only once per app, usually in the main app.py.
9
+ # If set here, it might override or conflict. Generally, avoid in sub-pages unless necessary
10
+ # and ensure it's compatible with the main app.py's layout.
11
+ # For consistency, let's assume app.py sets the global layout.
12
+ # st.set_page_config(page_title=f"Home - {settings.APP_TITLE}", layout="wide")
13
 
14
+ # --- Authentication Check ---
15
+ if not st.session_state.get("authenticated_user_id"):
16
  st.warning("Please log in to access the application.")
17
+ # Redirect to the main app page (which handles login)
18
+ # Make sure 'app.py' is the correct name of your main script.
19
+ try:
20
+ st.switch_page("app.py")
21
+ except st.errors.StreamlitAPIException as e:
22
+ if "st.switch_page can only be called when running in MPA mode" in str(e):
23
+ app_logger.warning("Running in single-page mode or st.switch_page issue. Stopping script.")
24
+ st.info("Please navigate to the main login page.")
25
+ else:
26
+ app_logger.error(f"Error during st.switch_page: {e}")
27
+ st.error("Redirection error. Please go to the login page manually.")
28
  st.stop() # Stop script execution if not authenticated
29
 
30
  # --- Page Content ---
31
+ # Get username from session state
32
+ authenticated_username = st.session_state.get("authenticated_username", "User") # Fallback to "User"
33
+
34
+ st.title(f"Welcome to {settings.APP_TITLE}, {authenticated_username}!")
35
+ st.markdown(f"""
36
+ Welcome, **{authenticated_username}**!
37
+
38
+ This application leverages cutting-edge AI to provide insights for healthcare professionals.
39
 
40
  **Features:**
41
  - **AI-Powered Consultation:** Engage in a conversation with an AI assistant capable of understanding medical queries,
42
+ looking up information, and more.
 
 
43
  - **Secure User Authentication:** Your data and interactions are protected.
44
  - **Reporting:** Generate PDF summaries of your consultations.
45
 
 
51
  actual medical decision-making without verification by qualified medical professionals.*
52
  """)
53
 
54
+ # Display Logo using the centralized get_logo_path
55
+ logo_path_str = get_logo_path()
56
+ if logo_path_str:
57
+ logo_file = Path(logo_path_str)
58
+ if logo_file.exists():
59
+ try:
60
+ st.image(str(logo_file), width=150, caption=settings.APP_TITLE)
61
+ except Exception as e:
62
+ app_logger.warning(f"Could not display logo on Home page from path '{logo_path_str}': {e}")
63
+ # else: # No need to log again if get_logo_path already logged it
64
+ # app_logger.warning(f"Home page logo path from get_logo_path() does not exist: {logo_path_str}")
65
+ elif settings.APP_TITLE: # Fallback to text if no logo
66
+ st.caption(f"Image: {settings.APP_TITLE} Logo")
67
+
68
+ app_logger.info(f"User {authenticated_username} accessed Home page.")