harishaseebat92 commited on
Commit
b8c9ea0
·
1 Parent(s): 6045475

correctly configured for a platform like Hugging Face Spaces

Browse files
app.py CHANGED
@@ -88,10 +88,8 @@ with SinglePageLayout(server) as layout:
88
  trame_html.Div(f"QLBM embed failed: {e}", style="padding:8px;color:#b00020;")
89
 
90
  if __name__ == "__main__":
91
- # If PORT is provided (e.g., Hugging Face), bind on 0.0.0.0; otherwise use localhost
92
- env_port = os.environ.get("PORT")
93
- port = int(env_port or os.environ.get("HF_PORT", "7860"))
94
- host = "0.0.0.0" if env_port else "127.0.0.1"
95
- server.start(host=host, port=port, open_browser=False)
96
 
97
 
 
88
  trame_html.Div(f"QLBM embed failed: {e}", style="padding:8px;color:#b00020;")
89
 
90
  if __name__ == "__main__":
91
+ # For Hugging Face, use the PORT env var and listen on 0.0.0.0
92
+ port = int(os.environ.get("PORT", 7860))
93
+ server.start(host="0.0.0.0", port=port, open_browser=False)
 
 
94
 
95
 
pages/__pycache__/em_page.cpython-310.pyc CHANGED
Binary files a/pages/__pycache__/em_page.cpython-310.pyc and b/pages/__pycache__/em_page.cpython-310.pyc differ
 
pages/__pycache__/qlbm_page.cpython-310.pyc CHANGED
Binary files a/pages/__pycache__/qlbm_page.cpython-310.pyc and b/pages/__pycache__/qlbm_page.cpython-310.pyc differ
 
qlbm_trame.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import sys
3
+
4
+ # Configure VTK for headless rendering BEFORE any VTK imports
5
+ if os.environ.get("PORT") or os.environ.get("HF_PORT") or os.environ.get("SPACE_ID"):
6
+ os.environ["MESA_GL_VERSION_OVERRIDE"] = "3.2"
7
+ os.environ["MESA_GLSL_VERSION_OVERRIDE"] = "150"
8
+ os.environ["GALLIUM_DRIVER"] = "llvmpipe"
9
+ # Force VTK to use OSMesa for offscreen rendering
10
+ os.environ["VTK_DEFAULT_EGL_DEVICE_INDEX"] = "-1"
11
+
12
+ # ...existing imports...