arahrooh commited on
Commit
b224160
·
1 Parent(s): 7a05627

Add final demo check for Spaces

Browse files
Files changed (1) hide show
  1. app.py +11 -1
app.py CHANGED
@@ -926,8 +926,18 @@ else:
926
  # Local execution: demo will be created in main()
927
  demo = None
928
 
 
 
 
 
 
 
 
 
 
 
929
  # For local execution only (not on Spaces)
930
  if __name__ == "__main__":
931
  # Don't run main() on Spaces - demo is already created at module level
932
- if not (os.getenv("SPACE_ID") or os.getenv("SYSTEM") == "spaces"):
933
  main()
 
926
  # Local execution: demo will be created in main()
927
  demo = None
928
 
929
+ # Final check: ensure demo is set for Spaces
930
+ if IS_SPACES and demo is None:
931
+ logger.error("CRITICAL: Demo is None on Spaces! Creating fallback demo.")
932
+ try:
933
+ with gr.Blocks() as fallback_demo:
934
+ gr.Markdown("# Error: Demo was not created properly\n\nPlease check the logs for details.")
935
+ demo = fallback_demo
936
+ except:
937
+ pass
938
+
939
  # For local execution only (not on Spaces)
940
  if __name__ == "__main__":
941
  # Don't run main() on Spaces - demo is already created at module level
942
+ if not IS_SPACES:
943
  main()