Spaces:
Running on Zero
Running on Zero
Download app.py from BergarBro/EDAN20_Lab6_Language_Translator: direct link, hf CLI and curl.
- Browser
- Download file 766 Bytes
-
https://huggingface.co/spaces/BergarBro/EDAN20_Lab6_Language_Translator/resolve/main/app.py
- Command line
-
hf download hf://spaces/BergarBro/EDAN20_Lab6_Language_Translator/app.py
-
curl -L -o app.py https://huggingface.co/spaces/BergarBro/EDAN20_Lab6_Language_Translator/resolve/main/app.py
766 Bytes
| import gradio as gr | |
| import spaces | |
| operations = ["Addition","Subtraction","Multiplication","Division"] | |
| def calculation(a,op,b): | |
| if op == operations[0] : | |
| return a + b | |
| if op == operations[1] : | |
| return a - b | |
| if op == operations[2] : | |
| return a * b | |
| if op == operations[3] : | |
| return a / b | |
| with gr.Blocks() as demo : | |
| gr.Markdown("My First App") | |
| num1 = gr.Number(label="First Number") | |
| num2 = gr.Number(label="Second Number") | |
| op = gr.Dropdown(choices=operations,label="Typ of Operation") | |
| add_button = gr.Button("Add") | |
| output = gr.Number(label="Reslut") | |
| add_button.click( | |
| fn=calculation, | |
| inputs=[num1,op,num2], | |
| outputs=output | |
| ) | |
| demo.launch() | |