Spaces:
Runtime error
Runtime error
LPX55
Refactor app.py to utilize shared functions for greeting, calculation, and image processing, enhancing modularity and code reuse. Introduce space loading tabs for dynamic integration of popular Hugging Face Spaces.
4cc700d
import gradio as gr | |
from shared_functions import calculator, download_csv | |
def calculator_tab(): | |
gr.Markdown("## Toy Calculator") | |
with gr.Row(): | |
with gr.Column(): | |
num1 = gr.Number(label="Number 1", info="First number") | |
operation = gr.Radio(["add", "subtract", "multiply", "divide"], label="Operation", info="Choose the operation") | |
num2 = gr.Number(label="Number 2", info="Second number") | |
calc_btn = gr.Button("Calculate") | |
with gr.Column(): | |
calc_output = gr.Number(label="Result") | |
download_calc_btn = gr.DownloadButton(label="Download Result", value=download_csv, inputs=calc_output) | |
gr.Examples( | |
[[45, "add", 3], [3.14, "divide", 2], [144, "multiply", 2.5], [0, "subtract", 1.2]], | |
inputs=[num1, operation, num2], | |
outputs=calc_output, | |
fn=calculator | |
) | |
calc_btn.click(calculator, [num1, operation, num2], calc_output) |