You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
698 B
Python
21 lines
698 B
Python
7 months ago
|
from flask import Flask, request, jsonify
|
||
|
import subprocess
|
||
|
|
||
|
app = Flask(__name__)
|
||
|
|
||
|
@app.route('/osiris_execute', methods=['POST'])
|
||
|
def execute_script():
|
||
|
data = request.get_json()
|
||
|
command = data.get('command')
|
||
|
if command:
|
||
|
try:
|
||
|
result = subprocess.run(['python','-c', command], capture_output=True, text=True, shell=True)
|
||
|
return jsonify({'output': result.stdout, 'error': result.stderr, 'returncode': result.returncode})
|
||
|
except Exception as exc:
|
||
|
return jsonify({'error': str(exc)}), 500
|
||
|
|
||
|
return jsonify({'error': 'Keinen gültigen Befehl gesendet.'}), 400
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
app.run(host='0.0.0.0', port=9713)
|