File size: 560 Bytes
66047a7
47494bd
2554d1b
66047a7
778b2e6
7518f92
2554d1b
 
2d67d33
d0f9afc
2554d1b
 
 
2958d0e
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import gradio as gr
import subprocess
import os

def greet(command):
    commandList = command.split(' ')
    if(commandList[0] == "cd"):
        os.chdir(commandList[1])
        output = subprocess.run(['pwd'], stdout=subprocess.PIPE).stdout.decode('utf-8')
        return f"{command}: \n {output}"
    else:
        output = subprocess.run(commandList, stdout=subprocess.PIPE).stdout.decode('utf-8')
        return f"{command}: \n {output}"

demo = gr.Interface(fn=greet, inputs="textbox", outputs="textbox")
    
if __name__ == "__main__":
    demo.launch()