Spaces:
mashroo
/
Runtime error

YoussefAnso commited on
Commit
8b8d633
·
1 Parent(s): f6283a6

Update Gradio launch settings to enable API endpoint with name "predict" while simplifying the configuration for both local and Spaces environments, enhancing usability and performance.

Browse files
Files changed (1) hide show
  1. app.py +11 -21
app.py CHANGED
@@ -268,25 +268,15 @@ with gr.Blocks(
268
  # Launch with Spaces-specific settings
269
  if __name__ == "__main__":
270
  import os
271
- from spaces.zero.gradio import launch # Use Spaces specific launch function
272
 
273
- if os.environ.get("SPACE_ID") is not None: # We're running on Hugging Face Spaces
274
- launch(
275
- demo,
276
- server_name="0.0.0.0",
277
- server_port=7860,
278
- show_error=True,
279
- enable_queue=True,
280
- max_threads=1,
281
- api_name=None, # Disable API endpoint generation
282
- share=False, # Don't use share on Spaces
283
- prevent_thread_lock=True # Prevent thread lock issues
284
- )
285
- else: # Local development
286
- demo.launch(
287
- server_name="0.0.0.0",
288
- server_port=7860,
289
- show_error=True,
290
- share=True, # Only use share=True for local development
291
- api_name=None # Disable API endpoint
292
- )
 
268
  # Launch with Spaces-specific settings
269
  if __name__ == "__main__":
270
  import os
 
271
 
272
+ # Use standard Gradio launch with API enabled
273
+ demo.launch(
274
+ server_name="0.0.0.0",
275
+ server_port=7860,
276
+ show_error=True,
277
+ enable_queue=True,
278
+ max_threads=1,
279
+ api_name="predict", # Enable API endpoint with name "predict"
280
+ share=False, # Don't use share on Spaces
281
+ prevent_thread_lock=True # Prevent thread lock issues
282
+ )