Update app.py
Browse files
app.py
CHANGED
@@ -24,6 +24,18 @@ def execute_snippet(code_snippet: str = DEF_SNIPPET, lang: str = DEF_LANG) -> st
|
|
24 |
return result.stdout.strip() # Return the standard output
|
25 |
except subprocess.CalledProcessError as e:
|
26 |
return f"Error: {e.stderr.strip()}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
case _: lang_param = lang.lower()
|
28 |
|
29 |
# FIXME: ERROR HANDLING
|
@@ -47,7 +59,7 @@ demo = gr.Interface(
|
|
47 |
gr.Dropdown(
|
48 |
show_label=True,
|
49 |
label="Language",
|
50 |
-
choices=["Python", "Java", "C", "C++", "C#", "PHP", "Bash"],
|
51 |
value=DEF_LANG
|
52 |
),
|
53 |
],
|
@@ -56,4 +68,4 @@ demo = gr.Interface(
|
|
56 |
description="Enter the code snippet and language that you want to execute.",
|
57 |
)
|
58 |
|
59 |
-
demo.launch()
|
|
|
24 |
return result.stdout.strip() # Return the standard output
|
25 |
except subprocess.CalledProcessError as e:
|
26 |
return f"Error: {e.stderr.strip()}"
|
27 |
+
case "Zsh": # Handle Zsh code execution
|
28 |
+
try:
|
29 |
+
# Execute the Zsh command and capture the output
|
30 |
+
result = subprocess.run(
|
31 |
+
["zsh", "-c", code_snippet],
|
32 |
+
capture_output=True,
|
33 |
+
text=True,
|
34 |
+
check=True
|
35 |
+
)
|
36 |
+
return result.stdout.strip() # Return the standard output
|
37 |
+
except subprocess.CalledProcessError as e:
|
38 |
+
return f"Error: {e.stderr.strip()}"
|
39 |
case _: lang_param = lang.lower()
|
40 |
|
41 |
# FIXME: ERROR HANDLING
|
|
|
59 |
gr.Dropdown(
|
60 |
show_label=True,
|
61 |
label="Language",
|
62 |
+
choices=["Python", "Java", "C", "C++", "C#", "PHP", "Bash", "Zsh"],
|
63 |
value=DEF_LANG
|
64 |
),
|
65 |
],
|
|
|
68 |
description="Enter the code snippet and language that you want to execute.",
|
69 |
)
|
70 |
|
71 |
+
demo.launch()
|