from flask import Flask, request, render_template_string import subprocess app = Flask(__name__) HTML_PAGE = """ Local Shell Test

Run Command



    


"""

@app.route('/')
def index():
    return render_template_string(HTML_PAGE)

@app.route('/run', methods=['POST'])
def run_cmd():
    data = request.get_json()
    cmd = data.get('cmd')
    try:
        result = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT, text=True)
    except subprocess.CalledProcessError as e:
        result = e.output
    return result

if __name__ == "__main__":
    app.run(debug=True)