from flask import Flask, request, render_template_string import subprocess app = Flask(__name__) HTML_TEMPLATE = """ NetView Pro v4.2

NetView Pro v4.2 - Diagnostic Tool

{% if result %}
{{ result }}
{% endif %} """ @app.route('/', methods=['GET', 'POST']) def index(): result = "" if request.method == 'POST': target = request.form.get('target') or (request.json.get('target') if request.is_json else None) if target: command = f"ping -c 2 {target}" try: output = subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT, text=True) result = output except Exception as e: result = str(getattr(e, 'output', str(e))) return render_template_string(HTML_TEMPLATE, result=result) if __name__ == '__main__': app.run(host='0.0.0.0', port=5000)