Spaces:
Sleeping
Sleeping
Upload main.py
Browse files315 unmodified lines31631731831932032132219 unmodified lines342343344345346347348349350351315 unmodified lineselse:# Automatically derive ws endpoint backend URLhost_header = request.headers.get("host", "localhost:49999")protocol = "wss" if request.url.scheme == "https" else "ws"backend_url = f"{protocol}://{host_header}/ws/live"# Render template using Jinja219 unmodified lineswith open(article_path, "w", encoding="utf-8") as f:f.write(html_content)# Build public shareable URL, respecting proxy headers for HTTPShost_header = request.headers.get("host", "localhost:49999")proto = request.headers.get("x-forwarded-proto", request.url.scheme)shareable_url = f"{proto}://{host_header}/static/articles/{article_filename}"print(f"[DEBUG] Constructed permanent article hosted at: {shareable_url}", flush=True)315 unmodified lines31631731831932032132232319 unmodified lines343344345346347348349350351352353354355356357358359360361362363315 unmodified lineselse:# Automatically derive ws endpoint backend URLhost_header = request.headers.get("host", "localhost:49999")proto = request.headers.get("x-forwarded-proto", request.url.scheme)protocol = "wss" if proto == "https" else "ws"backend_url = f"{protocol}://{host_header}/ws/live"# Render template using Jinja219 unmodified lineswith open(article_path, "w", encoding="utf-8") as f:f.write(html_content)# Build public shareable URL, respecting custom_backend_url if providedif custom_backend_url and custom_backend_url.strip():custom_host = custom_backend_url.strip()for prefix in ["wss://", "ws://", "https://", "http://"]:if custom_host.startswith(prefix):custom_host = custom_host[len(prefix):]custom_host = custom_host.split("/")[0] # Get host domain only# Determine protocol schemeproto = "https" if ("https" in custom_backend_url or "wss" in custom_backend_url) else "http"shareable_url = f"{proto}://{custom_host}/static/articles/{article_filename}"else:host_header = request.headers.get("host", "localhost:49999")proto = request.headers.get("x-forwarded-proto", request.url.scheme)shareable_url = f"{proto}://{host_header}/static/articles/{article_filename}"print(f"[DEBUG] Constructed permanent article hosted at: {shareable_url}", flush=True)
main.py+17-5