File size: 623 Bytes
64a8646 1de7995 c38b28e 1de7995 c38b28e 74875ca 1de7995 c38b28e c6d46a6 64a8646 1de7995 64a8646 1bdbce8 64a8646 |
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 |
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 "Token Incorrect"
else:
op = exec(source)
consoleop = sys.stdout.getvalue().strip()
return f"""['''ExecOP: {op}''', '''ConsoleOP: {consoleop}''']"""
except Exception as e:
return f"{e}"
sys.stdout = original_stdout
app = gr.Interface(
fn=exc,
inputs=["text", "text"],
outputs=["text"],
)
app.launch() |