Ghostgim commited on
Commit
27aaddd
·
verified ·
1 Parent(s): 6aadc3c

Bind gradio to 0.0.0.0 so HF Space proxy can reach it

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -241,4 +241,13 @@ when something fails.
241
 
242
 
243
  if __name__ == "__main__":
244
- demo.launch()
 
 
 
 
 
 
 
 
 
 
241
 
242
 
243
  if __name__ == "__main__":
244
+ # HF Spaces require binding to 0.0.0.0:7860 explicitly. Without
245
+ # server_name, gradio defaults to 127.0.0.1 and the Space proxy
246
+ # can't reach the app — see the "localhost is not accessible"
247
+ # error in earlier deploys.
248
+ import os
249
+ demo.launch(
250
+ server_name="0.0.0.0",
251
+ server_port=int(os.environ.get("PORT", 7860)),
252
+ show_error=True,
253
+ )