From 93180745181f0101540e1188850c5aaae68f76d2 Mon Sep 17 00:00:00 2001 From: mifi Date: Thu, 24 Jul 2025 11:55:48 -0300 Subject: [PATCH] Final autoconfig/autodiscover tweaks - and a prettier landing! --- app.py | 148 +++++++++++++++++++++++++++++++++++++++++++++ docker-compose.yml | 2 +- 2 files changed, 149 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 72abba2..bc89a37 100644 --- a/app.py +++ b/app.py @@ -9,6 +9,154 @@ env = jinja2.Environment( @app.route('/') def index(): + subdomain = request.host.split('.', 1)[0] + domain = request.host.split('.', 1)[1] if '.' in request.host else request.host + + base_html = """ + + + + + + {title} + + + +
+
{icon}
+ {service_type} +

{title}

+
Domain: {domain}
+ {content} + 📊 Service Status +
+ + + """ + + if subdomain == 'autoconfig': + return base_html.format( + title="Mail Autoconfig Service", + service_type="Mozilla Thunderbird", + icon="🔧", + domain=domain, + content=f''' +
+
Thunderbird Autoconfig Endpoint:
+ https://{request.host}/mail/config-v1.1.xml +
+ ''' + ) + elif subdomain == 'autodiscover': + return base_html.format( + title="Mail Autodiscover Service", + service_type="Microsoft Outlook", + icon="🔍", + domain=domain, + content=f''' +
+
Outlook Autodiscover Endpoint:
+ https://{request.host}/Autodiscover/Autodiscover.xml +
+ ''' + ) + else: + return base_html.format( + title="Mail Configuration Service", + service_type="Error", + icon="❌", + domain="Invalid", + content=''' +
+ Invalid subdomain!
+ Please use autoconfig.domain.com or autodiscover.domain.com +
+ ''' + ), 400 + +@app.route('/ping') +def ping(): return "Mail Autoconfig Service is running." @app.route('/mail/config-v1.1.xml') diff --git a/docker-compose.yml b/docker-compose.yml index 7c2d6e1..9592c79 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,7 @@ services: container_name: mifi-mail-autoconfig restart: unless-stopped healthcheck: - test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:80/')"] + test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:80/ping')"] interval: 30s timeout: 10s retries: 3