mouse and keyboard controllers for windows and linux
This commit is contained in:
29
desktop_env/windows_server/main.py
Normal file
29
desktop_env/windows_server/main.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from flask import Flask, request, jsonify
|
||||
import subprocess
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
@app.route('/execute', methods=['POST'])
|
||||
def execute_command():
|
||||
data = request.json
|
||||
# The 'command' key in the JSON request should contain the command to be executed.
|
||||
command = data.get('command', '')
|
||||
|
||||
# Execute the command without any safety checks.
|
||||
try:
|
||||
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
stdout, stderr = process.communicate()
|
||||
|
||||
return jsonify({
|
||||
'status': 'success',
|
||||
'output': stdout.decode(),
|
||||
'error': stderr.decode()
|
||||
})
|
||||
except Exception as e:
|
||||
return jsonify({
|
||||
'status': 'error',
|
||||
'message': str(e)
|
||||
}), 500
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True, host="0.0.0.0")
|
||||
Reference in New Issue
Block a user