mcp-projectile / app.py
rsivasam's picture
Update app.py
b7a93fc verified
# Credit to original author https://ai.gopubby.com/build-mcp-servers-and-host-them-for-free-a54a3bd24513
import gradio as gr
import math
def compute_projectile_distance(initial_speed, angle):
"""
Calculate the horizontal distance traveled by a projectile.
Parameters:
initial_speed (float): Initial speed of the projectile in m/s
angle (float): Launch angle in degrees
Returns:
float: Horizontal distance traveled in meters
"""
# Convert angle from degrees to radians
angle_rad = math.radians(angle)
# Gravitational acceleration (m/s²)
g = 9.81
# Calculate the horizontal distance using the projectile motion formula:
# distance = (initial_speed² * sin(2*angle)) / g
distance = (initial_speed**2 * math.sin(2 * angle_rad)) / g
print("Distance of the projectile: ", distance)
return distance
app = gr.Interface(
fn=compute_projectile_distance,
inputs=["number", "number"],
outputs="number",
title="Compute Projectile Distance",
description="CDC-1 (V1): Computes the theoretical horizontal distance a projectile travels for a given initial speed and angle."
)
#app.launch(mcp_server=True, share=True)
app.launch(server_name="0.0.0.0", server_port=7860, ssl_verify=False)