import gradio as gr from quiz import generate_quiz with gr.Blocks() as quiz_app: gr.Markdown("# AI Quiz Generator") with gr.Row(): with gr.Column(scale=2): topic_input = gr.Textbox( label="Quiz Topic", placeholder="Enter the topic for the quiz (e.g., Photosynthesis, World War II)", lines=1 ) with gr.Column(): num_questions = gr.Slider( label="Number of Questions", minimum=1, maximum=10, step=1, value=5 ) with gr.Row(): difficulty = gr.Radio( label="Difficulty Level", choices=["Beginner", "Intermediate", "Advanced"], value="Intermediate" ) generate_btn = gr.Button("Generate Quiz", variant="primary", size="lg") quiz_output = gr.Markdown( "Your generated quiz will appear here.", label="Generated Quiz", ) generate_btn.click( fn=generate_quiz, inputs=[topic_input, num_questions, difficulty], outputs=quiz_output ) quiz_app.launch()