Araeynn commited on
Commit
1de7995
1 Parent(s): 64a8646

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -2
app.py CHANGED
@@ -1,8 +1,25 @@
1
  import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  app = gr.Interface(
4
- fn=exec,
5
- inputs=["text"],
6
  outputs=["text"],
7
  )
8
 
 
1
  import gradio as gr
2
+ from io import StringIO
3
+ import sys
4
+
5
+ original_stdout = sys.stdout
6
+ sys.stdout = StringIO()
7
+
8
+ def exc(source, token):
9
+ if token != os.environ["special_token"]:
10
+ return "Token Incorrect"
11
+ else:
12
+ consoleop = ""
13
+ try:
14
+ op = exec(source=source)
15
+ consoleop = sys.stdout.getvalue().strip()
16
+ return f"""['''ExecOP: {op}''', '''ConsoleOP: {consoleop}''']"""
17
+ except Exception as e:
18
+ return f"{e}"
19
 
20
  app = gr.Interface(
21
+ fn=exc,
22
+ inputs=["text", "text"],
23
  outputs=["text"],
24
  )
25