Spaces:
Sleeping
Sleeping
File size: 676 Bytes
682a837 cfc5425 682a837 cfc5425 682a837 cfc5425 682a837 cfc5425 |
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 |
import gradio as gr
import time
def calculate_with_delay(expression):
time.sleep(6) # Simple 6-second delay
try:
result = eval(expression) # Calculate the expression
return f"After 6 seconds, {expression} = {result}"
except:
return "Invalid math expression"
with gr.Blocks() as demo:
gr.Markdown("# Math Calculator with 6s Delay")
with gr.Row():
input_text = gr.Textbox(label="Enter math expression (e.g., 1+8+9)")
result = gr.Textbox(label="Result")
btn = gr.Button("Calculate")
btn.click(
fn=calculate_with_delay,
inputs=input_text,
outputs=result
)
demo.launch() |