Update app.py
Browse files
app.py
CHANGED
@@ -42,7 +42,7 @@ class CodeExecutor:
|
|
42 |
error_text = error.read()
|
43 |
if error_text:
|
44 |
return f"User Code:\n{code}\n\nError:\n{error_text}"
|
45 |
-
return f"User Code:\n{code}\n\nOutput:\n{output_text}"
|
46 |
|
47 |
def execute(self, code, inputs, packages):
|
48 |
try:
|
@@ -68,12 +68,21 @@ def wrapper_execute(code, inputs, packages):
|
|
68 |
|
69 |
def create_interface():
|
70 |
with gr.Blocks() as demo:
|
71 |
-
gr.Markdown("# Code
|
72 |
-
gr.Markdown("
|
|
|
|
|
73 |
code_input = gr.Textbox(label="Code", lines=20)
|
|
|
|
|
74 |
inputs_input = gr.Textbox(label="Inputs (comma-separated)", lines=1)
|
75 |
-
|
|
|
|
|
|
|
|
|
76 |
output_text = gr.Text(label="Output", lines=20)
|
|
|
77 |
run_button = gr.Button("Run")
|
78 |
run_button.click(
|
79 |
wrapper_execute,
|
|
|
42 |
error_text = error.read()
|
43 |
if error_text:
|
44 |
return f"User Code:\n{code}\n\nError:\n{error_text}"
|
45 |
+
return f"User Code:\n{code}\n\nInputs:\n{', '.join(inputs)}\n\nOutput:\n{output_text}"
|
46 |
|
47 |
def execute(self, code, inputs, packages):
|
48 |
try:
|
|
|
68 |
|
69 |
def create_interface():
|
70 |
with gr.Blocks() as demo:
|
71 |
+
gr.Markdown("# Code Executor")
|
72 |
+
gr.Markdown("Execute Python code with inputs and packages")
|
73 |
+
|
74 |
+
gr.Markdown("### Code")
|
75 |
code_input = gr.Textbox(label="Code", lines=20)
|
76 |
+
|
77 |
+
gr.Markdown("### Inputs")
|
78 |
inputs_input = gr.Textbox(label="Inputs (comma-separated)", lines=1)
|
79 |
+
|
80 |
+
gr.Markdown("### Packages")
|
81 |
+
packages_input = gr.Textbox(label="Packages (comma-separated)", lines=1)
|
82 |
+
|
83 |
+
gr.Markdown("### Output")
|
84 |
output_text = gr.Text(label="Output", lines=20)
|
85 |
+
|
86 |
run_button = gr.Button("Run")
|
87 |
run_button.click(
|
88 |
wrapper_execute,
|