|
|
import streamlit as st |
|
|
import pandas as pd |
|
|
|
|
|
st.set_page_config(page_title="AI Engineer Flashcards", page_icon="🧠") |
|
|
|
|
|
st.title("AI Engineer Flashcards - BCG X Prep") |
|
|
|
|
|
@st.cache_data |
|
|
def load_flashcards(): |
|
|
return pd.read_csv("flashcards.csv").values.tolist() |
|
|
|
|
|
flashcards_list = load_flashcards() |
|
|
|
|
|
if 'index' not in st.session_state: |
|
|
st.session_state.index = 0 |
|
|
|
|
|
if 'show_back' not in st.session_state: |
|
|
st.session_state.show_back = False |
|
|
|
|
|
col1, col2, col3 = st.columns(3) |
|
|
|
|
|
|
|
|
with col1: |
|
|
if st.button("Show Back"): |
|
|
st.session_state.show_back = not st.session_state.show_back |
|
|
|
|
|
with col2: |
|
|
if st.button("Previous Card"): |
|
|
st.session_state.index = (st.session_state.index - 1) % len(flashcards_list) |
|
|
st.session_state.show_back = False |
|
|
|
|
|
with col3: |
|
|
if st.button("Next Card"): |
|
|
st.session_state.index = (st.session_state.index + 1) % len(flashcards_list) |
|
|
st.session_state.show_back = False |
|
|
|
|
|
|
|
|
front_list = [card[0] for card in flashcards_list] |
|
|
|
|
|
selected_front = st.selectbox("Select a card", front_list, index=st.session_state.index) |
|
|
|
|
|
|
|
|
st.session_state.index = front_list.index(selected_front) |
|
|
|
|
|
|
|
|
front, back = flashcards_list[st.session_state.index] |
|
|
|
|
|
st.markdown(f"### {front}") |
|
|
|
|
|
if st.session_state.show_back: |
|
|
st.info(back) |
|
|
|
|
|
st.caption("Powered by HuggingFace Spaces + Streamlit ✨") |
|
|
|