import gradio as gr import time # Timer function def start_timer(seconds): # Countdown loop for remaining in range(seconds, 0, -1): time.sleep(1) # Wait for 1 second yield f"{remaining} seconds remaining..." return "Time's up!" # Create Gradio interface with gr.Blocks() as demo: gr.Markdown("## Timer App") # Display the header for the page with gr.Row(): time_input = gr.Slider(minimum=1, maximum=600, step=1, label="Set Timer (seconds)") start_button = gr.Button("Start Timer") # Button to start timer timer_output = gr.Textbox(label="Timer Output", interactive=False) # Connect the button with the timer function start_button.click(start_timer, inputs=time_input, outputs=timer_output) # Launch the Gradio interface demo.launch()