xcx0902 commited on
Commit
4338994
·
verified ·
1 Parent(s): 781db96

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import io
3
+ import sys
4
+
5
+ def run(code):
6
+ old_stdout = sys.stdout
7
+ sys.stdout = buffer = io.StringIO()
8
+ try:
9
+ exec(code, {})
10
+ except Exception as e:
11
+ print(f"Error: {e}")
12
+ finally:
13
+ sys.stdout = old_stdout
14
+ return buffer.getvalue()
15
+
16
+ demo = gr.Interface(fn=run, inputs="text", outputs="text")
17
+ demo.launch()