Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import subprocess
|
| 3 |
|
|
|
|
| 4 |
def fn(txt):
|
| 5 |
command = ["python", "-u", "script.py"]
|
| 6 |
process = subprocess.Popen(
|
|
@@ -10,6 +11,9 @@ def fn(txt):
|
|
| 10 |
universal_newlines=True,
|
| 11 |
)
|
| 12 |
|
|
|
|
|
|
|
|
|
|
| 13 |
for line in process.stdout:
|
| 14 |
yield txt + line
|
| 15 |
|
|
@@ -18,6 +22,9 @@ def fn(txt):
|
|
| 18 |
if return_code:
|
| 19 |
raise subprocess.CalledProcessError(return_code, command)
|
| 20 |
|
|
|
|
| 21 |
with gr.Blocks() as demo:
|
| 22 |
txt = gr.Code()
|
| 23 |
-
demo.load(fn, inputs=txt, outputs=txt)
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import subprocess
|
| 3 |
|
| 4 |
+
|
| 5 |
def fn(txt):
|
| 6 |
command = ["python", "-u", "script.py"]
|
| 7 |
process = subprocess.Popen(
|
|
|
|
| 11 |
universal_newlines=True,
|
| 12 |
)
|
| 13 |
|
| 14 |
+
if process.stdout is None:
|
| 15 |
+
raise ValueError("stdout is None")
|
| 16 |
+
|
| 17 |
for line in process.stdout:
|
| 18 |
yield txt + line
|
| 19 |
|
|
|
|
| 22 |
if return_code:
|
| 23 |
raise subprocess.CalledProcessError(return_code, command)
|
| 24 |
|
| 25 |
+
|
| 26 |
with gr.Blocks() as demo:
|
| 27 |
txt = gr.Code()
|
| 28 |
+
demo.load(fn, inputs=txt, outputs=txt)
|
| 29 |
+
|
| 30 |
+
demo.launch()
|