Update arp.py
This commit is contained in:
parent
d44be13d7d
commit
61ec8b669b
1 changed files with 1 additions and 7 deletions
8
arp.py
8
arp.py
|
|
@ -5,7 +5,6 @@ from flask import Flask, render_template_string, jsonify
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
# Functie om de cURL-oproep te doen voor de ARP-tabel
|
|
||||||
def run_curl_command():
|
def run_curl_command():
|
||||||
curl_command = [
|
curl_command = [
|
||||||
"curl", "-k", "--location", "--request", "POST", "https://ip:port/show",
|
"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)
|
response = subprocess.check_output(curl_command, text=True)
|
||||||
return json.loads(response)
|
return json.loads(response)
|
||||||
|
|
||||||
# Functie om de ARP-gegevens te verwerken
|
|
||||||
def parse_arp_data(data):
|
def parse_arp_data(data):
|
||||||
arp_table = []
|
arp_table = []
|
||||||
|
|
||||||
if "data" in data:
|
if "data" in data:
|
||||||
raw_data = data["data"]
|
raw_data = data["data"]
|
||||||
|
|
||||||
# Verwerk de gegevens per regel
|
|
||||||
for line in raw_data.split("\n"):
|
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()
|
arp_info = line.split()
|
||||||
if len(arp_info) >= 4:
|
if len(arp_info) >= 4:
|
||||||
arp_table.append({
|
arp_table.append({
|
||||||
|
|
@ -36,7 +33,6 @@ def parse_arp_data(data):
|
||||||
|
|
||||||
return arp_table
|
return arp_table
|
||||||
|
|
||||||
# Functie om de ARP-tabel in HTML te genereren
|
|
||||||
def generate_html_table(arp_table):
|
def generate_html_table(arp_table):
|
||||||
html_template = """
|
html_template = """
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
|
@ -140,7 +136,6 @@ def generate_html_table(arp_table):
|
||||||
|
|
||||||
return html_output
|
return html_output
|
||||||
|
|
||||||
# Route om de ARP-tabel weer te geven als HTML
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
def arp_table_summary():
|
def arp_table_summary():
|
||||||
data = run_curl_command()
|
data = run_curl_command()
|
||||||
|
|
@ -151,7 +146,6 @@ def arp_table_summary():
|
||||||
|
|
||||||
return render_template_string(html_output)
|
return render_template_string(html_output)
|
||||||
|
|
||||||
# Route om de ARP-tabel als JSON weer te geven
|
|
||||||
@app.route('/json')
|
@app.route('/json')
|
||||||
def arp_table_summary_json():
|
def arp_table_summary_json():
|
||||||
data = run_curl_command()
|
data = run_curl_command()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue