milwright commited on
Commit
bb535c4
·
1 Parent(s): 0840baa

Fix HuggingFace Spaces launch configuration

Browse files

- Add detection for HuggingFace Spaces environment variables
- Configure server to bind to 0.0.0.0 on port 7860 for Spaces
- Disable share mode in Spaces to avoid localhost access errors

Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -1980,7 +1980,14 @@ if __name__ == "__main__":
1980
  }
1981
 
1982
  # Override settings for specific environments
1983
- if os.environ.get('CODESPACES'):
 
 
 
 
 
 
 
1984
  launch_kwargs.update({
1985
  "server_name": "0.0.0.0",
1986
  "share": True
 
1980
  }
1981
 
1982
  # Override settings for specific environments
1983
+ if os.environ.get('SPACE_ID') or os.environ.get('SPACE_HOST'):
1984
+ # HuggingFace Spaces environment
1985
+ launch_kwargs.update({
1986
+ "server_name": "0.0.0.0",
1987
+ "server_port": 7860,
1988
+ "share": False
1989
+ })
1990
+ elif os.environ.get('CODESPACES'):
1991
  launch_kwargs.update({
1992
  "server_name": "0.0.0.0",
1993
  "share": True