Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import requests | |
| # URL to fetch the quiz data from | |
| data_url = "https://raw.githubusercontent.com/dibend/flashcards/main/json/comptia_a%2B_1101.json" | |
| # Function to fetch quiz data | |
| def fetch_quiz_data(url): | |
| response = requests.get(url) | |
| response.raise_for_status() | |
| return response.json() | |
| # Fetch the quiz data | |
| quiz_data = fetch_quiz_data(data_url) | |
| # Ensure quiz_data structure | |
| flashcards = quiz_data.get('comptia_a+_1101', []) | |
| if not flashcards: | |
| raise ValueError("No flashcards found in the quiz data.") | |
| # Function to create the Gradio interface | |
| def create_interface(): | |
| with gr.Blocks() as demo: | |
| for flashcard in flashcards: | |
| with gr.Accordion(flashcard.get('question', 'Invalid question format'), open=False): | |
| gr.Markdown(flashcard.get('answer', 'No answer provided')) | |
| return demo | |
| # Create and launch the Gradio interface | |
| demo = create_interface() | |
| demo.launch() |