Spaces:
Paused
Paused
Commit
·
95ebb99
1
Parent(s):
71be4ea
Create main.py
Browse files
main.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import subprocess
|
| 3 |
+
import shlex
|
| 4 |
+
|
| 5 |
+
def execute_command(command):
|
| 6 |
+
result = subprocess.run(shlex.split(command), stdout=subprocess.PIPE).stdout.decode('utf-8')
|
| 7 |
+
return str(result)
|
| 8 |
+
|
| 9 |
+
inputs = gr.inputs.Textbox(default="print('Hello, world!')", lines=3)
|
| 10 |
+
output = gr.outputs.Textbox()
|
| 11 |
+
|
| 12 |
+
iface = gr.Interface(
|
| 13 |
+
execute_command,
|
| 14 |
+
inputs,
|
| 15 |
+
output,
|
| 16 |
+
title="Command Executor",
|
| 17 |
+
description="Enter a Python command and see the result.")
|
| 18 |
+
|
| 19 |
+
iface.launch()
|