Spaces:
Sleeping
Sleeping
Add application file
Browse files
app.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from modal_app import app, square
|
| 3 |
+
|
| 4 |
+
def compute_square(x):
|
| 5 |
+
"""Compute the square of a number.
|
| 6 |
+
|
| 7 |
+
Args:
|
| 8 |
+
x (float | int): The number to square.
|
| 9 |
+
|
| 10 |
+
Returns:
|
| 11 |
+
float: The square of the input number.
|
| 12 |
+
"""
|
| 13 |
+
with app.run():
|
| 14 |
+
return square.remote(float(x))
|
| 15 |
+
|
| 16 |
+
# Create a standard Gradio interface
|
| 17 |
+
demo = gr.Interface(
|
| 18 |
+
fn=compute_square,
|
| 19 |
+
inputs=gr.Number(label="Enter a number"),
|
| 20 |
+
outputs=gr.Number(label="Square of the number"),
|
| 21 |
+
title="Compute Square using Modal",
|
| 22 |
+
description="Enter a number to compute its square using a remote Modal function."
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
# Launch both the Gradio web interface and the MCP server
|
| 26 |
+
if __name__ == "__main__":
|
| 27 |
+
demo.launch(mcp_server=True)
|