zz
Browse files
app.py
CHANGED
|
@@ -1,32 +1,28 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
| 4 |
-
if operation == "add":
|
| 5 |
-
return num1 + num2
|
| 6 |
-
elif operation == "subtract":
|
| 7 |
-
return num1 - num2
|
| 8 |
-
elif operation == "multiply":
|
| 9 |
-
return num1 * num2
|
| 10 |
-
elif operation == "divide":
|
| 11 |
-
if num2 == 0:
|
| 12 |
-
raise gr.Error("Cannot divide by zero!")
|
| 13 |
-
return num1 / num2
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
demo = gr.Blocks()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
+
def dummy(tb, sl):
|
| 6 |
+
tbo = tb + " " + " "+ str(sl)
|
| 7 |
+
num = sl
|
| 8 |
+
print(tb + " " + " "+ str(sl))
|
| 9 |
+
cb = ['usa', 'japan', ]
|
| 10 |
+
if sl > 50:
|
| 11 |
+
raise gr.Error("This is not allowed!!!!!!!")
|
| 12 |
+
return tbo, num, cb
|
| 13 |
+
|
| 14 |
+
with demo:
|
| 15 |
+
tb = gr.Textbox()
|
| 16 |
+
sl = gr.Slider(minimum=1, maximum=100, step=5, info="hhe hhah kki ko")
|
| 17 |
+
b1 = gr.Button('button')
|
| 18 |
+
tbo = gr.Textbox()
|
| 19 |
+
num = gr.Number()
|
| 20 |
+
cb = gr.CheckboxGroup(label = "countries", choices= ["india", "usa", "japan"], value="usa")
|
| 21 |
+
b1.click(dummy, [tb, sl], [tbo, num, cb] )
|
| 22 |
+
|
| 23 |
+
examples = gr.Examples([["dd", 1], ["ggg", 4], ["kjkjk", 6]],
|
| 24 |
+
[tb, sl],
|
| 25 |
+
[tbo, num, cb],
|
| 26 |
+
dummy, cache_examples=True)
|
| 27 |
|
| 28 |
demo.launch()
|