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