Spaces:
Sleeping
Sleeping
File size: 1,026 Bytes
890aa18 |
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 32 33 34 35 36 |
import gradio as gr
def add(a, b):
return a + b
def multiply(a, b):
return a * b
def greet(name):
return f"Hello, {name}!"
demo = gr.Blocks()
with demo:
gr.Markdown("# Simple Calculator and Greeter")
gr.Markdown("This demo includes two simple functions: addition, multiplication, and a greeting.")
with gr.Tab("Addition"):
a = gr.Number(label="Number 1")
b = gr.Number(label="Number 2")
result = gr.Number(label="Result")
gr.Button("Add").click(add, inputs=[a, b], outputs=result)
with gr.Tab("Multiplication"):
a2 = gr.Number(label="Number 1")
b2 = gr.Number(label="Number 2")
result2 = gr.Number(label="Result")
gr.Button("Multiply").click(multiply, inputs=[a2, b2], outputs=result2)
with gr.Tab("Greeting"):
name = gr.Textbox(label="Your Name")
greeting = gr.Textbox(label="Greeting")
gr.Button("Greet").click(greet, inputs=[name], outputs=greeting)
if __name__ == "__main__":
demo.launch() |