Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import gradio as gr
|
2 |
import io
|
3 |
import sys
|
|
|
4 |
|
5 |
class PersistentRunner:
|
6 |
def __init__(self):
|
@@ -22,7 +23,10 @@ class PersistentRunner:
|
|
22 |
runner = PersistentRunner()
|
23 |
|
24 |
def run(code):
|
25 |
-
|
|
|
|
|
|
|
26 |
|
27 |
demo = gr.Interface(fn=run, inputs="text", outputs="text")
|
28 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import io
|
3 |
import sys
|
4 |
+
import os
|
5 |
|
6 |
class PersistentRunner:
|
7 |
def __init__(self):
|
|
|
23 |
runner = PersistentRunner()
|
24 |
|
25 |
def run(code):
|
26 |
+
if code.startswith("!"):
|
27 |
+
os.system(code[1:])
|
28 |
+
else:
|
29 |
+
return runner.run(code.replace("\\n", "\n"))
|
30 |
|
31 |
demo = gr.Interface(fn=run, inputs="text", outputs="text")
|
32 |
demo.launch()
|