File size: 678 Bytes
b2c9a39
59ae140
b2c9a39
59ae140
 
b2c9a39
59ae140
 
 
 
 
 
b2c9a39
59ae140
bfd563a
59ae140
 
b2c9a39
59ae140
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import subprocess
import gradio as gr

# Fungsi untuk menjalankan command
def run_command(command):
    try:
        # Jalankan command via subprocess
        result = subprocess.run(command, shell=True, capture_output=True, text=True)
        if result.returncode == 0:
            return result.stdout  # Output command berhasil
        else:
            return f"Error: {result.stderr}"  # Output error kalau command gagal
    except Exception as e:
        return f"Exception occurred: {str(e)}"  # Handle error

# Interface dengan Gradio
iface = gr.Interface(fn=run_command, inputs="text", outputs="text", title="Command Runner")

# Jalankan Gradio Interface
iface.launch()