Spaces:
Running
Running
File size: 6,814 Bytes
d1da800 7917008 a2ec2d3 4a23d33 d1da800 889b952 d1da800 889b952 d1da800 63a7f01 1ecc668 f49f36a d1da800 46e47b6 d1da800 46e47b6 1ecc668 46e47b6 d1da800 63a7f01 d1da800 46e47b6 d1da800 46e47b6 7917008 63a7f01 cb4004b 7917008 63a7f01 dd039c2 49e3aec ae38d1c 4a23d33 63732ac 31653a7 f49f36a 63a7f01 d1da800 f49f36a 7917008 4a23d33 7917008 d1da800 |
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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
import streamlit as st
import os
import glob
import sys
import numpy as np
import plotly.graph_objects as go
from sklearn.linear_model import LinearRegression
import nltk
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize, sent_tokenize
# Add the current directory to the Python path
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
# Import the login component
from components.login import login
# Import week pages
from course_pages import week_1
from course_pages import week_2
from course_pages import week_3
from course_pages import week_4
from course_pages import week_5
from course_pages import week_6
from course_pages import week_7
from course_pages import week_8
from course_pages import week_9
# Page configuration
st.set_page_config(
page_title="Data Science Course App",
page_icon="π",
layout="wide",
initial_sidebar_state="expanded",
menu_items={
'Get Help': None,
'Report a bug': None,
'About': None
}
)
# Disable URL paths and hide Streamlit elements
st.markdown("""
<style>
#MainMenu {visibility: hidden;}
footer {visibility: hidden;}
.stDeployButton {display: none;}
.viewerBadge_container__1QSob {display: none;}
/* Hide Streamlit's automatic page navigation */
[data-testid="stSidebarNav"] {display: none !important;}
.css-1d391kg {display: none !important;}
.css-1lcbmhc {display: none !important;}
.css-1v0mbdj {display: none !important;}
.css-1wivap2 {display: none !important;}
.css-1y4p8pa {display: none !important;}
/* Hide any automatic navigation elements */
[data-testid="stSidebar"] [data-testid="stSidebarNav"] {display: none !important;}
/* Hide the automatic page navigation that appears at the top */
.css-1d391kg {display: none !important;}
.css-1lcbmhc {display: none !important;}
.css-1v0mbdj {display: none !important;}
.css-1wivap2 {display: none !important;}
.css-1y4p8pa {display: none !important;}
/* Additional selectors to hide automatic navigation */
.css-1d391kg {display: none !important;}
.css-1lcbmhc {display: none !important;}
.css-1v0mbdj {display: none !important;}
.css-1wivap2 {display: none !important;}
.css-1y4p8pa {display: none !important;}
</style>
""", unsafe_allow_html=True)
# Custom CSS
def load_css():
try:
with open('assets/style.css') as f:
st.markdown(f'<style>{f.read()}</style>', unsafe_allow_html=True)
except FileNotFoundError:
# Fallback for Streamlit Cloud deployment
st.markdown("""
<style>
/* Main title styling */
.main .block-container h1 {
color: #2c3e50;
font-size: 2.5rem;
margin-bottom: 1rem;
}
/* Subtitle styling */
.main .block-container h2 {
color: #34495e;
font-size: 1.8rem;
margin-top: 2rem;
margin-bottom: 1rem;
}
/* Button styling */
.stButton>button {
width: 100%;
border-radius: 5px;
height: 3em;
margin: 0.5em 0;
background-color: #3498db;
color: white;
border: none;
}
.stButton>button:hover {
background-color: #2980b9;
}
/* Progress bar styling */
.stProgress > div > div {
background-color: #2ecc71;
}
/* Info box styling */
.stAlert {
border-radius: 5px;
padding: 1rem;
margin: 1rem 0;
}
/* Code block styling */
.stCodeBlock {
background-color: #f8f9fa;
border-radius: 5px;
padding: 1rem;
margin: 1rem 0;
}
</style>
""", unsafe_allow_html=True)
# Initialize session state
if 'current_week' not in st.session_state:
st.session_state.current_week = 1
if 'logged_in' not in st.session_state:
st.session_state.logged_in = False
# Sidebar navigation
def sidebar_navigation():
with st.sidebar:
st.title("Course Navigation")
# Show username if logged in
if st.session_state.logged_in:
st.write(f"Welcome, {st.session_state.username}!")
# Debug button to show current week
if st.session_state.username == "admin":
if st.button("Debug: Show Current Week"):
st.write(f"Current week: {st.session_state.current_week}")
# Logout button
if st.button("Logout"):
st.session_state.logged_in = False
st.session_state.username = None
st.rerun()
st.markdown("---")
st.subheader("Course Content")
# Create a container for week buttons
week_container = st.container()
# Add week buttons with custom styling
with week_container:
for week in range(1, 11):
if st.button(f"Week {week}", key=f"week_{week}"):
st.session_state.current_week = week
st.rerun()
def show_week_content():
# Debug print to show current week
#st.write(f"Debug: Current week is {st.session_state.current_week}")
if st.session_state.current_week == 1:
week_1.show()
elif st.session_state.current_week == 2:
week_2.show()
elif st.session_state.current_week == 3:
week_3.show()
elif st.session_state.current_week == 4:
week_4.show()
elif st.session_state.current_week == 5:
week_5.show()
elif st.session_state.current_week == 6:
week_6.show()
elif st.session_state.current_week == 7:
week_7.show()
elif st.session_state.current_week == 8:
week_8.show()
elif st.session_state.current_week == 9:
week_9.show()
else:
st.warning("Content for this week is not yet available.")
# Main content
def main():
# Check if user is logged in
if not st.session_state.logged_in:
# Show login page
login()
return
# User is logged in, show course content
if st.session_state.current_week in [1, 2, 3, 4, 5, 6, 7, 8, 9]:
show_week_content()
else:
st.title("Data Science Research Paper Course")
st.markdown("""
## Welcome to the Data Science Research Paper Course! π
This section has not been released yet.
""")
if __name__ == "__main__":
load_css()
sidebar_navigation()
main() |