Spaces:
Running
Running
File size: 1,804 Bytes
d291776 |
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 |
""" Flashcards generator using LLM as a backend """
import streamlit as st
# from dotenv import find_dotenv, load_dotenv
from flashcard import Flashcards
# Importing page modules
from import_export_page import show_import_export_page
from show_generator_page import show_generator_page
def main():
"""
Main function to run the Streamlit app for flashcard generation and management.
This function initializes the app, setting up the page configuration and session state.
It provides navigation between the flashcard generator and import/export pages.
"""
# Load environment variables from .env file
# load_dotenv(find_dotenv())
# Set Streamlit page configuration
st.set_page_config(page_title="FG", layout="centered", initial_sidebar_state="auto")
# Initialize flashcards in session state if not already present
if "flashcards" not in st.session_state:
st.session_state.flashcards = Flashcards([])
# Initialize expand_all toggle state in session state
if "expand_all" not in st.session_state:
st.session_state.expand_all = False
# Define navigation options
generator_choice = "π€ Generator"
import_export_choice = "π Import/Export"
# Sidebar for navigation
with st.sidebar:
# Display application logo
st.image(
"https://github.com/mikkac/flashcards_generator/blob/main/resources/logo.png?raw=true"
)
# Radio buttons for page selection
choice = st.radio("Select Page", (generator_choice, import_export_choice))
# Conditional rendering of pages based on user choice
if choice == generator_choice:
show_generator_page()
elif choice == import_export_choice:
show_import_export_page()
if __name__ == "__main__":
main()
|