To upload files, please first save the app
import streamlit as st
import os
import base64
st.set_page_config(page_title="Academy Lessons Viewer", layout="wide")
st.title("📚 Academy Lessons Viewer")
LESSONS_DIR = "lessons"
# Get list of lessons
lessons = sorted([f for f in os.listdir(LESSONS_DIR) if os.path.isdir(os.path.join(LESSONS_DIR, f))])
def show_pdf(pdf_file_path):
with open(pdf_file_path, "rb") as f:
base64_pdf = base64.b64encode(f.read()).decode("utf-8")
pdf_display = f'<iframe src="data:application/pdf;base64,{base64_pdf}" width="100%" height="600px" type="application/pdf"></iframe>'
st.markdown(pdf_display, unsafe_allow_html=True)
# Display each lesson in an expander
for lesson in lessons:
lesson_path = os.path.join(LESSONS_DIR, lesson)
pdf_path = os.path.join(lesson_path, "notes.pdf")
video_path = os.path.join(lesson_path, "video.mp4")
with st.expander(f"📘 {lesson.title()}"):
if os.path.exists(pdf_path):
st.subheader("📄 Lesson Notes")
show_pdf(pdf_path)
else:
st.warning("No PDF found for this lesson.")
if os.path.exists(video_path):
st.subheader("🎬 Lesson Video")
st.video(video_path)
else:
st.warning("No video found for this lesson.")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?