import sys
from pathlib import Path
import os
import gdown
import streamlit as st
# Set page config - must be first Streamlit command
st.set_page_config(
page_title="TruthCheck - Advanced Fake News Detector",
page_icon="đĄī¸",
layout="wide",
initial_sidebar_state="expanded"
)
# Custom CSS with Poppins font
st.markdown("""
""", unsafe_allow_html=True)
MODEL_PATH = "models/saved/final_model.pt"
GOOGLE_DRIVE_FILE_ID = "1xhYKuC5_Yri3mm3Ejt-SpB2WAVUTJvc_"
GOOGLE_DRIVE_URL = f"https://drive.google.com/uc?id={GOOGLE_DRIVE_FILE_ID}"
@st.cache_resource
def download_model():
"""Download model from Google Drive if not exists."""
if not os.path.exists(MODEL_PATH):
os.makedirs(os.path.dirname(MODEL_PATH), exist_ok=True)
with st.spinner("Downloading model from Google Drive..."):
try:
gdown.download(GOOGLE_DRIVE_URL, MODEL_PATH, quiet=False)
st.markdown('
Model downloaded successfully!
', unsafe_allow_html=True)
except Exception as e:
st.markdown(f'Failed to download model: {str(e)}
', unsafe_allow_html=True)
st.markdown('Please check your Google Drive link and ensure the file is publicly accessible.
', unsafe_allow_html=True)
return False
return True
# Add src directory to Python path
src_path = Path(__file__).parent / "src"
sys.path.append(str(src_path))
# Enhanced Sidebar navigation with icons
st.sidebar.markdown("""
đĄī¸
TruthCheck
Advanced Fake News Detector
""", unsafe_allow_html=True)
st.sidebar.markdown("---")
# Navigation with icons
page = st.sidebar.radio(
"Navigate",
[
"đ Home",
"âšī¸ About",
"đ Open Source",
"đ Terms of Use",
"đ Privacy Policy",
"đŦ Contact"
],
label_visibility="collapsed",
key="navigation"
)
# Add some spacing and additional info
st.sidebar.markdown("---")
st.sidebar.markdown("""
đ
Protecting you from misinformation with AI-powered detection
""", unsafe_allow_html=True)
# Add footer info in sidebar only
st.sidebar.markdown("""
Š 2025 TruthCheck | AI-Powered
""", unsafe_allow_html=True)
# Clean up the page variable to remove icons for the conditional logic
page_clean = page.split(" ", 1)[1] if " " in page else page
if __name__ == "__main__":
if page_clean == "Home":
if download_model():
from src.app import main
main()
else:
st.markdown('Cannot start the application without the model file.
', unsafe_allow_html=True)
elif page_clean == "About":
from src.about import main
main()
elif page_clean == "About":
from src.open_source import main
main()
elif page_clean == "Terms of Use":
from src.terms_of_use import main
main()
elif page_clean == "Privacy Policy":
from src.privacy_policy import main
main()
elif page_clean == "Contact":
from src.contact import main
main()