Update app/main.py
Browse files- app/main.py +4 -1
app/main.py
CHANGED
@@ -14,13 +14,16 @@ def index():
|
|
14 |
@socketio.on('input', namespace='/terminal')
|
15 |
def handle_input(data):
|
16 |
command = data['command']
|
|
|
17 |
result = execute_command(command)
|
18 |
emit('output', {'output': result})
|
19 |
|
20 |
def execute_command(command):
|
21 |
result = subprocess.run(['docker', 'exec', 'terminal-website_ubuntu_1', 'bash', '-c', command],
|
22 |
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
23 |
-
|
|
|
|
|
24 |
|
25 |
if __name__ == '__main__':
|
26 |
socketio.run(app, host='0.0.0.0', port=7860)
|
|
|
14 |
@socketio.on('input', namespace='/terminal')
|
15 |
def handle_input(data):
|
16 |
command = data['command']
|
17 |
+
print(f"Received command: {command}") # Debugging log
|
18 |
result = execute_command(command)
|
19 |
emit('output', {'output': result})
|
20 |
|
21 |
def execute_command(command):
|
22 |
result = subprocess.run(['docker', 'exec', 'terminal-website_ubuntu_1', 'bash', '-c', command],
|
23 |
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
24 |
+
output = result.stdout.decode('utf-8') + result.stderr.decode('utf-8')
|
25 |
+
print(f"Command output: {output}") # Debugging log
|
26 |
+
return output
|
27 |
|
28 |
if __name__ == '__main__':
|
29 |
socketio.run(app, host='0.0.0.0', port=7860)
|