update
This commit is contained in:
parent
8fabfbb916
commit
1d106d9c52
20
app.py
20
app.py
@ -1,12 +1,16 @@
|
||||
from flask import Flask, render_template
|
||||
import requests
|
||||
import re
|
||||
import docker
|
||||
import requests
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
TRAEFIK_API_URL = "https://norman.lan/api/http/routers"
|
||||
REGEX_PATTERNS = [r".*\.gederico\.dynu\.net"]
|
||||
|
||||
client = docker.from_env()
|
||||
containers = client.containers.list(all=True) # Get all containers
|
||||
|
||||
def get_routers():
|
||||
response = requests.get(TRAEFIK_API_URL, verify=False) # Ignore SSL certificate verification
|
||||
if response.status_code == 200:
|
||||
@ -28,13 +32,11 @@ def filter_routers(routers):
|
||||
def get_router_description(router_name):
|
||||
try:
|
||||
service_name = router_name.split('@')[0]
|
||||
response = requests.get("http://localhost:2375/containers/json?filters={%22name%22:[%22" + service_name + "%22]}")
|
||||
containers = response.json()
|
||||
if containers:
|
||||
container = containers[0]
|
||||
labels = container.get('Labels', {})
|
||||
print(labels)
|
||||
return labels.get('traefik.http.routers.' + service_name + '.description', 'No description available')
|
||||
for container in containers:
|
||||
labels = container.attrs.get('Config', {}).get('Labels', {})
|
||||
description = labels.get('traefik-frontend.http.routers.' + service_name + '.description')
|
||||
if description:
|
||||
return description
|
||||
except Exception as e:
|
||||
print(f"Error fetching description for {router_name}: {e}")
|
||||
return 'No description available'
|
||||
@ -50,5 +52,5 @@ def index():
|
||||
return render_template('index.html', routers=routers)
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(debug=True)
|
||||
app.run(host='0.0.0.0', debug=True)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user