Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -387,10 +387,22 @@ if __name__ == "__main__":
|
|
387 |
print("Example: export HUGGINGFACE_TOKEN=your_token_here")
|
388 |
exit(1)
|
389 |
|
390 |
-
#
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
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
|