HarmonyAI / server /app.py
stagbrook-tech's picture
Initial commit
ea7fd90
raw
history blame contribute delete
597 Bytes
"""
app.py
------
Flask server to handle command execution requests.
"""
from flask import Flask, request, jsonify
import subprocess
app = Flask(__name__)
@app.route("/execute", methods=["POST"])
def execute():
data = request.json
script = data["script"]
with open("temp_script.sh", "w") as file:
file.write(script)
subprocess.run(["chmod", "+x", "temp_script.sh"])
result = subprocess.run(["./temp_script.sh"], capture_output=True, text=True)
return jsonify({"output": result.stdout, "error": result.stderr})
if __name__ == "__main__":
app.run(port=5000)