Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,6 +12,17 @@ robj.r("""
|
|
| 12 |
""")
|
| 13 |
|
| 14 |
def arithmetic(num1, num2, operation):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
with localconverter(default_converter):
|
| 16 |
if operation == "Add":
|
| 17 |
res = robj.r(f"add({num1}, {num2})")
|
|
@@ -21,6 +32,7 @@ def arithmetic(num1, num2, operation):
|
|
| 21 |
res = robj.r(f"sub({num1}, {num2})")
|
| 22 |
elif operation == "Divide":
|
| 23 |
res = robj.r(f"div({num1}, {num2})")
|
|
|
|
| 24 |
return res[0]
|
| 25 |
|
| 26 |
|
|
@@ -28,7 +40,7 @@ def arithmetic(num1, num2, operation):
|
|
| 28 |
with gr.Blocks(
|
| 29 |
title="R-Powered Calculator",
|
| 30 |
theme=gr.themes.Glass(text_size='lg'),
|
| 31 |
-
css="footer {display: none !important;}"
|
| 32 |
) as app:
|
| 33 |
gr.HTML(
|
| 34 |
"<h1 style='text-align:center;'><strong>R-Powered Calculator</strong></h1>"
|
|
@@ -52,4 +64,4 @@ with gr.Blocks(
|
|
| 52 |
|
| 53 |
submit.click(arithmetic, inputs=[num1, num2, operation], outputs=[result])
|
| 54 |
|
| 55 |
-
app.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 12 |
""")
|
| 13 |
|
| 14 |
def arithmetic(num1, num2, operation):
|
| 15 |
+
"""
|
| 16 |
+
Perform arithmetic operations on two numbers.
|
| 17 |
+
|
| 18 |
+
Args:
|
| 19 |
+
num1 (int or float): The first number.
|
| 20 |
+
num2 (int or float): The second number.
|
| 21 |
+
operation (str): The operation to perform. Can be "Add", "Multiply", "Subtract", or "Divide".
|
| 22 |
+
Returns:
|
| 23 |
+
int or float: The result of the arithmetic operation.
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
with localconverter(default_converter):
|
| 27 |
if operation == "Add":
|
| 28 |
res = robj.r(f"add({num1}, {num2})")
|
|
|
|
| 32 |
res = robj.r(f"sub({num1}, {num2})")
|
| 33 |
elif operation == "Divide":
|
| 34 |
res = robj.r(f"div({num1}, {num2})")
|
| 35 |
+
|
| 36 |
return res[0]
|
| 37 |
|
| 38 |
|
|
|
|
| 40 |
with gr.Blocks(
|
| 41 |
title="R-Powered Calculator",
|
| 42 |
theme=gr.themes.Glass(text_size='lg'),
|
| 43 |
+
# css="footer {display: none !important;}"
|
| 44 |
) as app:
|
| 45 |
gr.HTML(
|
| 46 |
"<h1 style='text-align:center;'><strong>R-Powered Calculator</strong></h1>"
|
|
|
|
| 64 |
|
| 65 |
submit.click(arithmetic, inputs=[num1, num2, operation], outputs=[result])
|
| 66 |
|
| 67 |
+
app.launch(server_name="0.0.0.0", server_port=7860, mcp_server = True)
|