rousing / app.py
navkrishna's picture
udpated app.py with new calc code
0815b5a
raw
history blame
631 Bytes
import gradio as gr
def calculator(input_str):
try:
result = eval(input_str)
return result
except ZeroDivisionError:
return "Division by zero error"
except Exception as e:
return f"Error: {str(e)}"
# Create the Gradio interface
interface = gr.Interface(
fn=calculator,
inputs=gr.inputs.Textbox(lines=2, placeholder="Enter calculation (e.g., 3 + 5 * 2)", label="Calculator Input"),
outputs="text",
title="Simple Calculator",
description="Enter a mathematical expression to calculate the result."
)
# Launch the app
if __name__ == "__main__":
interface.launch()