Update app.py
Browse files
app.py
CHANGED
|
@@ -1,35 +1,45 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
| 3 |
import runpodctl
|
| 4 |
|
| 5 |
-
def
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
output = os.popen(command).read()
|
| 9 |
-
return output
|
| 10 |
-
else:
|
| 11 |
-
return "Bitte geben Sie einen Befehl ein."
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
|
|
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
|
|
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
-
def run_app(
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
return output
|
| 25 |
|
| 26 |
-
|
|
|
|
|
|
|
| 27 |
iface = gr.Interface(
|
| 28 |
fn=run_app,
|
| 29 |
-
inputs=
|
| 30 |
-
outputs=
|
| 31 |
-
title="
|
| 32 |
-
description="
|
| 33 |
theme="default"
|
| 34 |
)
|
| 35 |
-
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import subprocess
|
| 3 |
import runpodctl
|
| 4 |
|
| 5 |
+
def start_pod(pod_name):
|
| 6 |
+
result = subprocess.run(["runpodctl", "start", pod_name], capture_output=True, text=True)
|
| 7 |
+
return result.stdout
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
def stop_pod(pod_name):
|
| 10 |
+
result = subprocess.run(["runpodctl", "stop", pod_name], capture_output=True, text=True)
|
| 11 |
+
return result.stdout
|
| 12 |
|
| 13 |
+
def delete_pod(pod_name):
|
| 14 |
+
result = subprocess.run(["runpodctl", "delete", pod_name], capture_output=True, text=True)
|
| 15 |
+
return result.stdout
|
| 16 |
|
| 17 |
+
def create_pod(pod_name):
|
| 18 |
+
result = subprocess.run(["runpodctl", "create", pod_name], capture_output=True, text=True)
|
| 19 |
+
return result.stdout
|
| 20 |
|
| 21 |
+
def run_app(action, pod_name):
|
| 22 |
+
if action == "start":
|
| 23 |
+
output = start_pod(pod_name)
|
| 24 |
+
elif action == "stop":
|
| 25 |
+
output = stop_pod(pod_name)
|
| 26 |
+
elif action == "delete":
|
| 27 |
+
output = delete_pod(pod_name)
|
| 28 |
+
elif action == "create":
|
| 29 |
+
output = create_pod(pod_name)
|
| 30 |
+
else:
|
| 31 |
+
output = "Unknown action. Please select a valid action."
|
| 32 |
return output
|
| 33 |
|
| 34 |
+
action_options = gr.inputs.Radio(["start", "stop", "delete", "create"], label="Choose action")
|
| 35 |
+
pod_name_input = gr.inputs.Textbox(label="Enter pod name")
|
| 36 |
+
|
| 37 |
iface = gr.Interface(
|
| 38 |
fn=run_app,
|
| 39 |
+
inputs=[action_options, pod_name_input],
|
| 40 |
+
outputs="text",
|
| 41 |
+
title="Pod Management",
|
| 42 |
+
description="Enter the pod name and choose an action to perform on the pod.",
|
| 43 |
theme="default"
|
| 44 |
)
|
| 45 |
+
iface.launch()
|