v1.0.159: serve app.js via Python (nginx alias not working)

This commit is contained in:
2026-06-23 17:16:23 +04:00
parent 04ca79a489
commit 79b6554316
+17
View File
@@ -40,6 +40,8 @@ class Handler(BaseHTTPRequestHandler):
self._handle_process_v2(parsed)
elif parsed.path == "/health":
self._json({"ok": True, "db": DB_CONFIG["dbname"]})
elif parsed.path == "/app.js":
self._handle_app_js()
elif parsed.path == "/api/supplements":
self._handle_api_supplements(parsed)
elif parsed.path.startswith("/api/documents/"):
@@ -117,6 +119,21 @@ class Handler(BaseHTTPRequestHandler):
"elements_json": doc.get("elements_json"),
})
# ── /app.js (static) ───────────────────────────────────────────────────
def _handle_app_js(self):
try:
with open(os.path.join(os.path.dirname(__file__), "..", "app.js"), "rb") as f:
js = f.read()
self.send_response(200)
self.send_header("Content-Type", "application/javascript; charset=utf-8")
self.send_header("Content-Length", str(len(js)))
self._send_cors()
self.end_headers()
self.wfile.write(js)
except FileNotFoundError:
self.send_error(404)
# ── /upload ───────────────────────────────────────────────────────────
def _handle_upload(self):