Add mac launcher, py2app setup, and build script

Co-authored-by: Copilot <[email protected]>
This commit is contained in:
Pat TeruelandCopilot committed 2026-03-01 10:16:21 +08:00
1 parent 35d63c3726
commit c77c1a6f6f
5 files changed
+96 -1

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
#!/usr/bin/env python3
"""
Launcher for macOS .app bundle: starts the Flask server bound to 127.0.0.1 and opens the default browser.
"""
import os
import time
import threading
import webbrowser
# Import the Flask app defined in app.py
from app import app
def _run_server():
port = int(os.environ.get("PORT", 5000))
# Bind to loopback only for local use
app.run(host="127.0.0.1", port=port, debug=False, use_reloader=False)
if __name__ == "__main__":
t = threading.Thread(target=_run_server, daemon=True)
t.start()
# Give the server a moment to start
time.sleep(1.0)
port = os.environ.get("PORT", "5000")
url = f"http://127.0.0.1:{port}/"
try:
webbrowser.open(url)
except Exception:
# If opening the browser fails, just continue; user can open manually
pass
try:
# Keep the main thread alive while the server thread runs
while t.is_alive():
t.join(0.5)
except KeyboardInterrupt:
pass