File size: 1,600 Bytes
aa2b69f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d1c7508
aa2b69f
d1c7508
aa2b69f
d1c7508
aa2b69f
 
 
d1c7508
 
 
 
 
 
aa2b69f
 
 
d1c7508
 
 
 
 
 
 
 
 
52773e5
 
 
 
 
 
 
 
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
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)

# Mostrar los botones "Mostrar Reverso" y "Siguiente Carta"
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

# Mostrar la lista de anversos (front) en un selectbox para navegar rápidamente
front_list = [card[0] for card in flashcards_list]

selected_front = st.selectbox("Select a card", front_list, index=st.session_state.index)

# Actualizamos el índice con el valor seleccionado en el selectbox
st.session_state.index = front_list.index(selected_front)

# Mostrar el anverso y reverso de la carta seleccionada
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 ✨")