c2 / app.py
Araeynn's picture
Update app.py
3b18704 verified
raw
history blame contribute delete
586 Bytes
import gradio as gr
from io import StringIO
import sys
import os
original_stdout = sys.stdout
sys.stdout = StringIO()
def exc(source, token):
sys.stdout = StringIO()
try:
if token != os.environ["special_token"]:
return ["", ""]
else:
op = exec(source)
consoleop = sys.stdout.getvalue().strip()
return [op, consoleop]
except Exception as e:
return ["", f"{e}"]
sys.stdout = original_stdout
app = gr.Interface(
fn=exc,
inputs=["text", "text"],
outputs=["text", "text"],
)
app.launch()