-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathalt.py
More file actions
31 lines (24 loc) · 679 Bytes
/
Copy pathalt.py
File metadata and controls
31 lines (24 loc) · 679 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import platform
import subprocess
from shiny import App, render, ui
app_ui = ui.page_fluid(
ui.h2("Alternative:"),
ui.span("Python"),
ui.output_text_verbatim("python"),
ui.input_text_area("cmd", "Command to run", placeholder="Enter text"),
ui.output_text_verbatim("cmd_output"),
)
def server(input, output, session):
@output
@render.text
def python():
return platform.python_version()
@output
@render.text
def cmd_output():
cmd=input.cmd()
try:
return subprocess.check_output(cmd, shell=True).decode()
except Exception as e:
return f"Error: {e}"
app = App(app_ui, server)