Spaces:
Sleeping
Sleeping
import streamlit as st | |
from time import sleep | |
from streamlit.runtime.scriptrunner import get_script_run_ctx | |
from streamlit.source_util import get_pages | |
from pathlib import Path | |
from arabic_support import support_arabic_text | |
# مسیر فایل فعلی | |
current_file_path = Path(__file__).resolve() | |
# مسیر ریشه پروژه (دو سطح بالاتر از فایل فعلی) | |
project_root = current_file_path.parents[0] | |
# مسیرهای دایرکتوریها | |
assets_dir = project_root / "asset" | |
styles_dir = project_root / "styles" | |
support_arabic_text(all=True) | |
# خواندن فایل CSS | |
css_file_path = styles_dir / "main.css" | |
state = st.session_state | |
def get_current_page_name(): | |
ctx = get_script_run_ctx() | |
if ctx is None: | |
raise RuntimeError("Couldn't get script context") | |
pages = get_pages("") | |
return pages[ctx.page_script_hash]["page_name"] | |
def make_sidebar(): | |
support_arabic_text(all=True) | |
with open(css_file_path, "r", encoding="utf-8") as file: | |
css_code = file.read() | |
# اعمال CSS | |
st.markdown(f"<style>{css_code}</style>", unsafe_allow_html=True) | |
with st.sidebar: | |
st.title("💊 AI-Medical Questionnaire") | |
st.write("") | |
st.write("") | |
if state.get("logged_in", False): | |
st.page_link("pages/1_app.py", label="دستیار هوشمند", icon="💊") | |
st.page_link("pages/2_result.py", label="نتیجه بررسی", icon="💉") | |
st.page_link("pages/3_data_entry.py", label="فرم ورود اطلاعات پایگاه داده", icon="✅") | |
st.page_link("pages/4_About_us.py", label="درباره سازندگان", icon="🕵️") | |
st.page_link("pages/5_print_data.py", label="دریافت گزارش بررسی انجام گرفته", icon="📈") | |
st.page_link("pages/6_upload_to_db.py", label="ورود اطلاعات به پایگاه داده", icon="📝") | |
st.write("") | |
st.write("") | |
if st.button("Log out"): | |
logout() | |
elif get_current_page_name() != "main": | |
# If anyone tries to access a secret page without being logged in, | |
# redirect them to the login page | |
st.switch_page("main.py") | |
def logout(): | |
state.logged_in = False | |
st.info("Logged out successfully!") | |
sleep(0.5) | |
st.switch_page("main.py") |