Lenylvt commited on
Commit
dc8b11f
1 Parent(s): ec32201

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -8,11 +8,15 @@ BASE_DIR = "./brevet"
8
  # Utility function to list files for a given subject and type
9
  def get_files(subject, file_type):
10
  subject_path = os.path.join(BASE_DIR, subject)
11
- files = [f.replace(' Corrigé', '') for f in os.listdir(subject_path) if 'Corrigé' in f] if file_type == 'Corrigé' else [f for f in os.listdir(subject_path) if 'Corrigé' not in f]
 
 
 
 
12
  return sorted(files, reverse=True)
13
 
14
  # Streamlit app layout
15
- st.title("Sujets et Corrigés du Brevet (*Par Studyrama*)")
16
 
17
  # Subject selection
18
  subject = st.selectbox("Sélectionner la matière", ["Francais", "Mathématique", "Science", "Histoire-Géographie-EMC"])
@@ -24,8 +28,7 @@ file_type = st.selectbox("Sélectionner le type", ["Sujet", "Corrigé"])
24
  files = get_files(subject, file_type)
25
  selected_file = st.selectbox("Sélectionner l'année", files)
26
 
27
- selected_file_corrected = selected_file.replace('.pdf', '')
28
- file_name = f"{selected_file_corrected}{' Corrigé' if file_type == 'Corrigé' else ''}.pdf"
29
  file_path = os.path.join(BASE_DIR, subject, file_name)
30
 
31
  # Initialize or update session state for button press
 
8
  # Utility function to list files for a given subject and type
9
  def get_files(subject, file_type):
10
  subject_path = os.path.join(BASE_DIR, subject)
11
+ # Adjust to remove '.pdf' from filenames
12
+ if file_type == 'Corrigé':
13
+ files = [f.replace(' Corrigé.pdf', '') for f in os.listdir(subject_path) if 'Corrigé' in f]
14
+ else:
15
+ files = [f.replace('.pdf', '') for f in os.listdir(subject_path) if 'Corrigé' not in f and f.endswith('.pdf')]
16
  return sorted(files, reverse=True)
17
 
18
  # Streamlit app layout
19
+ st.title("Téléchargement des sujets et corrigés du Brevet")
20
 
21
  # Subject selection
22
  subject = st.selectbox("Sélectionner la matière", ["Francais", "Mathématique", "Science", "Histoire-Géographie-EMC"])
 
28
  files = get_files(subject, file_type)
29
  selected_file = st.selectbox("Sélectionner l'année", files)
30
 
31
+ file_name = f"{selected_file}{' Corrigé' if file_type == 'Corrigé' else ''}.pdf"
 
32
  file_path = os.path.join(BASE_DIR, subject, file_name)
33
 
34
  # Initialize or update session state for button press