freemt
Update gradio.Interface examples
80c38e5
raw
history blame
869 Bytes
"""Talk to spaces VM via subprocess.check_output."""
# import httpx
import subprocess as sp
from shlex import split
import gradio as gr
def greet(name):
"""Probe vm."""
try:
out = sp.check_output(split(name), encoding="utf8")
except Exception as e:
out = str(e)
# return "Hello " + name + "!!"
if not (out and out.strip()):
out = "No output, that's all we know."
return f"[{out}]"
iface = gr.Interface(
fn=greet,
inputs="text",
outputs="text",
examples=[
"cat /proc/version # show linux distro",
"free # show free memory",
"uname -m # show machine arch ",
"cat /proc/cpuinfo # show cpu info ",
],
title="probe the system",
description="talk to the system via subprocess.check_output ",
)
# iface.launch(share=True, debug=True)
iface.launch(debug=True)