commit 172bbaa82476762db4979822e15d7abca906ec5f Author: Federico Luzzi Date: Mon Jul 22 18:14:12 2024 -0300 first commit diff --git a/app.py b/app.py new file mode 100644 index 0000000..cbd4587 --- /dev/null +++ b/app.py @@ -0,0 +1,39 @@ +from flask import Flask, render_template +import requests +import re + +app = Flask(__name__) + +TRAEFIK_API_URL = "https://norman.lan/api/http/routers" +REGEX_PATTERNS = [r".*\.gederico\.dynu\.net"] + +def get_routers(): + response = requests.get(TRAEFIK_API_URL, verify=False) # Ignore SSL certificate verification + if response.status_code == 200: + routers = response.json() + filtered_routers = filter_routers(routers) + return filtered_routers + return [] + +def filter_routers(routers): + filtered_routers = [] + for router in routers: + for pattern in REGEX_PATTERNS: + if re.match(pattern, router['rule'].split('`')[1]): + filtered_routers.append(router) + break + return filtered_routers + +def truncate_and_uppercase_name(name): + return name.split('@')[0].upper() + +@app.route('/') +def index(): + routers = get_routers() + for router in routers: + router['truncated_name'] = truncate_and_uppercase_name(router['name']) + return render_template('index.html', routers=routers) + +if __name__ == '__main__': + app.run(debug=True) + diff --git a/static/styles.css b/static/styles.css new file mode 100644 index 0000000..249d03e --- /dev/null +++ b/static/styles.css @@ -0,0 +1,131 @@ +body { + font-family: Arial, sans-serif; + margin: 0; + background-color: #f9f9f9; + color: #333; + transition: background-color 0.3s, color 0.3s; +} + +.header { + background-color: #3f51b5; + color: white; + padding: 20px; + text-align: center; +} + +.header button { + background: none; + border: 2px solid white; + color: white; + padding: 10px 20px; + cursor: pointer; + margin-top: 10px; + border-radius: 5px; +} + +.header button:hover { + background-color: white; + color: #3f51b5; +} + +.content { + padding: 20px; +} + +.applications { + max-width: 1200px; + margin: 0 auto; +} + +.applications h2 { + color: #3f51b5; +} + +.router-container { + display: flex; + flex-wrap: wrap; + justify-content: space-between; +} + +.router { + background-color: white; + border-radius: 8px; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + padding: 20px; + margin: 10px; + flex: 1 1 calc(33.333% - 20px); + max-width: calc(33.333% - 20px); + text-align: center; + cursor: pointer; + transition: box-shadow 0.3s ease; + box-sizing: border-box; +} + +.router:hover { + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); +} + +.router h2 { + margin: 0; + color: #3f51b5; + text-transform: uppercase; +} + +/* Dark Mode */ +.dark-mode { + background-color: #121212; + color: #e0e0e0; +} + +.dark-mode .header { + background-color: #1e1e1e; +} + +.dark-mode .header button { + border-color: #e0e0e0; +} + +.dark-mode .header button:hover { + background-color: #e0e0e0; + color: #1e1e1e; +} + +.dark-mode .applications h2 { + color: #bb86fc; +} + +.dark-mode .router { + background-color: #1e1e1e; + color: #e0e0e0; +} + +.dark-mode .router h2 { + color: #bb86fc; +} + +.dark-mode .router:hover { + box-shadow: 0 4px 8px rgba(255, 255, 255, 0.2); +} + +/* Responsive Design */ +@media (max-width: 1024px) { + .router { + flex: 1 1 calc(50% - 20px); + max-width: calc(50% - 20px); + } +} + +@media (max-width: 768px) { + .router { + flex: 1 1 calc(50% - 20px); + max-width: calc(50% - 20px); + } +} + +@media (max-width: 480px) { + .router { + flex: 1 1 100%; + max-width: 100%; + } +} + diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..13e269e --- /dev/null +++ b/templates/index.html @@ -0,0 +1,40 @@ + + + + + + Traefik Routers + + + + +
+

Traefik Routers

+ +
+
+
+

Applications

+
+ {% for router in routers %} +
+

{{ router['truncated_name'] }}

+
+ {% endfor %} +
+
+
+ + +