CamiloVega commited on
Commit
c4dde0e
·
verified ·
1 Parent(s): 6b01013

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -7
app.py CHANGED
@@ -387,10 +387,22 @@ if __name__ == "__main__":
387
  print("Example: export HUGGINGFACE_TOKEN=your_token_here")
388
  exit(1)
389
 
390
- # Launch the application
391
- demo.launch(
392
- server_name="0.0.0.0",
393
- server_port=7860,
394
- share=False,
395
- show_error=True
396
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
387
  print("Example: export HUGGINGFACE_TOKEN=your_token_here")
388
  exit(1)
389
 
390
+ # Get sharing preference from environment
391
+ share_enabled = os.environ.get('SHARE_APP', 'false').lower() == 'true'
392
+ if share_enabled:
393
+ logger.info("Public sharing is enabled - a public URL will be generated")
394
+
395
+ try:
396
+ # Launch the application
397
+ demo.launch(
398
+ server_name="0.0.0.0", # Listen on all network interfaces
399
+ server_port=7860, # Default Gradio port
400
+ share=share_enabled, # Generate public URL if enabled
401
+ show_error=True, # Show detailed error messages
402
+ quiet=True # Reduce console output noise
403
+ )
404
+ except KeyboardInterrupt:
405
+ logger.info("Shutting down server...")
406
+ except Exception as e:
407
+ logger.error(f"Error launching server: {str(e)}")
408
+ raise