This commit is contained in:
Federico Luzzi 2024-07-22 18:25:30 -03:00
parent 172bbaa824
commit 8fabfbb916
3 changed files with 21 additions and 0 deletions

15
app.py
View File

@ -20,10 +20,25 @@ def filter_routers(routers):
for router in routers:
for pattern in REGEX_PATTERNS:
if re.match(pattern, router['rule'].split('`')[1]):
router['description'] = get_router_description(router['name'])
filtered_routers.append(router)
break
return filtered_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')
except Exception as e:
print(f"Error fetching description for {router_name}: {e}")
return 'No description available'
def truncate_and_uppercase_name(name):
return name.split('@')[0].upper()

View File

@ -71,6 +71,11 @@ body {
text-transform: uppercase;
}
.router p {
margin: 10px 0 0;
color: #666;
}
/* Dark Mode */
.dark-mode {
background-color: #121212;

View File

@ -30,6 +30,7 @@
{% for router in routers %}
<div class="router" onclick="location.href='http://{{ router['rule'].split('`')[1] }}'">
<h2>{{ router['truncated_name'] }}</h2>
<p>{{ router['description'] }}</p>
</div>
{% endfor %}
</div>