Update arp.py

This commit is contained in:
Blackwhitebear8 2025-01-12 17:35:44 +01:00
parent d44be13d7d
commit 61ec8b669b

8
arp.py
View file

@ -5,7 +5,6 @@ from flask import Flask, render_template_string, jsonify
app = Flask(__name__)
# Functie om de cURL-oproep te doen voor de ARP-tabel
def run_curl_command():
curl_command = [
"curl", "-k", "--location", "--request", "POST", "https://ip:port/show",
@ -15,16 +14,14 @@ def run_curl_command():
response = subprocess.check_output(curl_command, text=True)
return json.loads(response)
# Functie om de ARP-gegevens te verwerken
def parse_arp_data(data):
arp_table = []
if "data" in data:
raw_data = data["data"]
# Verwerk de gegevens per regel
for line in raw_data.split("\n"):
if line.strip() and not line.startswith("Address"):
if line.strip() and not line.startswith("Address") and "---" not in line:
arp_info = line.split()
if len(arp_info) >= 4:
arp_table.append({
@ -36,7 +33,6 @@ def parse_arp_data(data):
return arp_table
# Functie om de ARP-tabel in HTML te genereren
def generate_html_table(arp_table):
html_template = """
<!DOCTYPE html>
@ -140,7 +136,6 @@ def generate_html_table(arp_table):
return html_output
# Route om de ARP-tabel weer te geven als HTML
@app.route('/')
def arp_table_summary():
data = run_curl_command()
@ -151,7 +146,6 @@ def arp_table_summary():
return render_template_string(html_output)
# Route om de ARP-tabel als JSON weer te geven
@app.route('/json')
def arp_table_summary_json():
data = run_curl_command()