segovia commited on
Commit
860389a
·
1 Parent(s): 141799b
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -5,6 +5,9 @@ import csv
5
  import tempfile
6
  from pathlib import Path
7
 
 
 
 
8
  import gradio as gr
9
 
10
  from document_processing import extract_text, is_image_document, to_data_uri
@@ -121,4 +124,10 @@ demo = build_app()
121
 
122
 
123
  if __name__ == "__main__":
124
- demo.launch(server_name="0.0.0.0", server_port=7860, theme=gr.themes.Soft())
 
 
 
 
 
 
 
5
  import tempfile
6
  from pathlib import Path
7
 
8
+ # Avoid the Node.js SSR proxy in hosted environments where it can terminate unexpectedly.
9
+ os.environ.setdefault("GRADIO_SSR_MODE", "false")
10
+
11
  import gradio as gr
12
 
13
  from document_processing import extract_text, is_image_document, to_data_uri
 
124
 
125
 
126
  if __name__ == "__main__":
127
+ launch_kwargs = {"theme": gr.themes.Soft()}
128
+
129
+ # Spaces manages networking itself; local runs keep explicit host/port.
130
+ if os.getenv("SPACE_ID"):
131
+ demo.launch(**launch_kwargs)
132
+ else:
133
+ demo.launch(server_name="0.0.0.0", server_port=7860, **launch_kwargs)