delayed / app.py
SunForever's picture
Update app.py
cfc5425 verified
raw
history blame contribute delete
676 Bytes
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()