from flask import Flask from subprocess import run, PIPE app = Flask(__name__) @app.route('/run_command/') def run_command(command): # Define the command to run based on the URL parameter if command == 'neofetch': cmd = ['neofetch'] elif command == 'uptime': cmd = ['uptime'] elif command == 'upsc': cmd = ['upsc', 'ups'] else: return 'Invalid command' # Run the command and capture the output result = run(cmd, stdout=PIPE, stderr=PIPE, text=True) # Check if the command executed successfully if result.returncode == 0: # Wrap the output in
 tags to preserve formatting
        output = f'{result.stdout}'
        return output
    else:
        return f'Error running command: {result.stderr}'

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000, debug=True)