File size: 582 Bytes
64a8646
1de7995
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr
from io import StringIO
import sys

original_stdout = sys.stdout
sys.stdout = StringIO()

def exc(source, token):
    if token != os.environ["special_token"]:
        return "Token Incorrect"
    else:
        consoleop = ""
        try:
            op = exec(source=source)
            consoleop = sys.stdout.getvalue().strip()
            return f"""['''ExecOP: {op}''', '''ConsoleOP: {consoleop}''']"""
        except Exception as e:
            return f"{e}"

app = gr.Interface(
    fn=exc,
    inputs=["text", "text"],
    outputs=["text"],
)

app.launch()