File size: 651 Bytes
51857fd f276882 01531ac 57193ba f276882 51857fd 1878582 57193ba 3fcc68b 1878582 51857fd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import gradio
import subprocess
def run_command(command):
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
output, error = process.communicate()
if process.returncode == 0:
result = output.decode('utf-8')
return result
else:
result = error.decode('utf-8')
return result
gradio_interface = gradio.Interface(
fn=run_command,
inputs="text",
outputs="text",
examples=[
["ls -l"],
["pip install bs4"]
],
title="REST API ",
description="This is an AI powered REST API ",
article=""
)
gradio_interface.launch()
|