Spaces:
Runtime error
Runtime error
Download app.py from decodingdatascience/calculator9dec: direct link, hf CLI and curl.
- Browser
- Download file 551 Bytes
-
https://huggingface.co/spaces/decodingdatascience/calculator9dec/resolve/main/app.py
- Command line
-
hf download hf://spaces/decodingdatascience/calculator9dec/app.py
-
curl -L -o app.py https://huggingface.co/spaces/decodingdatascience/calculator9dec/resolve/main/app.py
551 Bytes
| import gradio as gr | |
| def calculator(operator, num1, num2): | |
| if operator == "+": | |
| result = num1 + num2 | |
| elif operator == "-": | |
| result = num1 - num2 | |
| elif operator == "*": | |
| result = num1 * num2 | |
| elif operator == "/": | |
| if num2 != 0: | |
| result = num1/num2 | |
| else: | |
| return "Error, Division by zero not allowed" | |
| else: | |
| return f"Error, {operator} is invalid. Please try again " | |
| return result | |
| iface = gr.Interface( fn=calculator, | |
| inputs=["text","number","number"], | |
| outputs="text") | |
| iface.launch(share=True) | |