VirtualOasis commited on
Commit
17b2eb4
·
verified ·
1 Parent(s): 12f8f41

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -1
app.py CHANGED
@@ -287,4 +287,42 @@ demo = gr.Interface(
287
  )
288
 
289
  if __name__ == "__main__":
290
- demo.launch(mcp_server=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
287
  )
288
 
289
  if __name__ == "__main__":
290
+ import os
291
+ import uvicorn
292
+ from contextlib import asynccontextmanager
293
+
294
+ # Try multiple approaches to fix the MCP server issues
295
+ try:
296
+ # Approach 1: Use environment variable instead of parameter
297
+ os.environ["GRADIO_MCP_SERVER"] = "True"
298
+
299
+ # Approach 2: Launch with specific server settings for better stability
300
+ demo.launch(
301
+ server_name="0.0.0.0",
302
+ server_port=7860,
303
+ share=False,
304
+ debug=False,
305
+ show_error=True,
306
+ show_api=True,
307
+ quiet=False,
308
+ # Remove mcp_server=True temporarily to avoid ASGI issues
309
+ # mcp_server=True
310
+ )
311
+ except Exception as e:
312
+ print(f"Primary launch failed: {e}")
313
+ print("Trying alternative launch method...")
314
+
315
+ # Approach 3: Fallback launch without MCP initially
316
+ try:
317
+ demo.launch(
318
+ server_name="0.0.0.0",
319
+ server_port=7860,
320
+ share=False,
321
+ debug=False
322
+ )
323
+ except Exception as e2:
324
+ print(f"Fallback launch also failed: {e2}")
325
+ print("Trying minimal launch...")
326
+
327
+ # Approach 4: Minimal launch
328
+ demo.launch()