Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
|
3 |
+
# Function to convert kilometers to meters or centimeters
|
4 |
+
def convert_distance(km, scale):
|
5 |
+
if scale == "Meters":
|
6 |
+
return km * 1000 # Convert to meters
|
7 |
+
elif scale == "Centimeters":
|
8 |
+
return km * 100000 # Convert to centimeters
|
9 |
+
|
10 |
+
# Gradio interface
|
11 |
+
iface = gr.Interface(
|
12 |
+
fn=convert_distance,
|
13 |
+
inputs=[
|
14 |
+
gr.Number(label="Distance in Kilometers"),
|
15 |
+
gr.Radio(["Meters", "Centimeters"], label="Select Unit")
|
16 |
+
],
|
17 |
+
outputs=gr.Number(label="Converted Distance")
|
18 |
+
)
|
19 |
+
|
20 |
+
# Launch the interface
|
21 |
+
iface.launch()
|