File size: 943 Bytes
5726a2f
 
 
ae7dcc6
 
 
 
addd5ca
 
f773523
ae7dcc6
5726a2f
ae7dcc6
addd5ca
5726a2f
ae7dcc6
f773523
ae7dcc6
 
5726a2f
addd5ca
 
 
ae7dcc6
9ae3bde
ae7dcc6
addd5ca
 
 
 
 
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
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()