| 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() |