Spaces:
Runtime error
Runtime error
from typing import Union | |
import gradio as gr | |
def divide(a: float, b: float) -> Union[float, str]: | |
"""Divide a by b.""" | |
try: | |
a, b = float(a), float(b) | |
if b == 0: | |
return "Error: Division by zero" | |
return a / b | |
except (ValueError, TypeError): | |
return "Error: Both inputs must be valid numbers" | |
divide_interface = gr.Interface( | |
fn=divide, | |
inputs=[gr.Number(label="A"), gr.Number(label="B")], | |
outputs="text", | |
title="Division", | |
description="Divide two numbers" | |
) | |