Dan Mo commited on
Commit
e11fd2f
·
1 Parent(s): 975f207

Refactor sharing functionality to conditionally set share parameter based on environment

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -8,6 +8,7 @@ from utils import logger
8
  from emoji_processor import EmojiProcessor
9
  from config import EMBEDDING_MODELS
10
  import random
 
11
 
12
  class EmojiMashupApp:
13
  def __init__(self):
@@ -258,11 +259,19 @@ class EmojiMashupApp:
258
  share: Whether to create a public sharing link
259
  """
260
  logger.info("Starting Emoji Mashup App")
 
261
  interface = self.create_interface()
 
 
 
 
 
 
 
262
  interface.launch(share=share)
263
 
264
 
265
  # Main entry point
266
  if __name__ == "__main__":
267
  app = EmojiMashupApp()
268
- app.run(share=True)
 
8
  from emoji_processor import EmojiProcessor
9
  from config import EMBEDDING_MODELS
10
  import random
11
+ import os
12
 
13
  class EmojiMashupApp:
14
  def __init__(self):
 
259
  share: Whether to create a public sharing link
260
  """
261
  logger.info("Starting Emoji Mashup App")
262
+
263
  interface = self.create_interface()
264
+ # Check if running on Hugging Face Spaces
265
+ is_on_spaces = os.environ.get("SPACE_ID") is not None
266
+
267
+ # Only set share=True if not on Spaces and share parameter is not explicitly set to False
268
+ if share is None:
269
+ share = not is_on_spaces
270
+
271
  interface.launch(share=share)
272
 
273
 
274
  # Main entry point
275
  if __name__ == "__main__":
276
  app = EmojiMashupApp()
277
+ app.run()