File size: 361 Bytes
4338994
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import gradio as gr
import io
import sys

def run(code):
    old_stdout = sys.stdout
    sys.stdout = buffer = io.StringIO()
    try:
        exec(code, {})
    except Exception as e:
        print(f"Error: {e}")
    finally:
        sys.stdout = old_stdout
    return buffer.getvalue()

demo = gr.Interface(fn=run, inputs="text", outputs="text")
demo.launch()