Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import os
|
| 3 |
+
import runpodctl
|
| 4 |
+
|
| 5 |
+
def run_command(command):
|
| 6 |
+
# Überprüfung, ob der Befehl eingegeben wurde
|
| 7 |
+
if command:
|
| 8 |
+
output = os.popen(command).read()
|
| 9 |
+
return output
|
| 10 |
+
else:
|
| 11 |
+
return "Bitte geben Sie einen Befehl ein."
|
| 12 |
+
|
| 13 |
+
# Texteingabefeld erstellen
|
| 14 |
+
command_input = gr.inputs.Textbox(label="Enter command")
|
| 15 |
+
|
| 16 |
+
# Senden-Button erstellen
|
| 17 |
+
send_button = gr.inputs.Button(label="Send")
|
| 18 |
+
|
| 19 |
+
# Ausgabe erstellen
|
| 20 |
+
output_text = gr.outputs.Text(label="Output")
|
| 21 |
+
|
| 22 |
+
def run_app(command):
|
| 23 |
+
output = run_command(command)
|
| 24 |
+
return output
|
| 25 |
+
|
| 26 |
+
# Gradio Space erstellen
|
| 27 |
+
iface = gr.Interface(
|
| 28 |
+
fn=run_app,
|
| 29 |
+
inputs=command_input + send_button,
|
| 30 |
+
outputs=output_text,
|
| 31 |
+
title="Terminal-Befehl ausführen",
|
| 32 |
+
description="Geben Sie den gewünschten Befehl ein und drücken Sie 'Senden', um den Befehl im Terminal auszuführen.",
|
| 33 |
+
theme="default"
|
| 34 |
+
)
|
| 35 |
+
iface.launch()
|