ACE-Step Custom commited on
Commit
2217362
·
1 Parent(s): d6ad90b

Fix fastapi_app attribute name and move endpoint override after launch

Browse files
Files changed (1) hide show
  1. app.py +15 -11
app.py CHANGED
@@ -658,23 +658,27 @@ if __name__ == "__main__":
658
  # Create and launch app
659
  app = create_ui()
660
 
661
- # Override /info endpoint to prevent JSON schema errors
662
- from fastapi.responses import JSONResponse
663
-
664
- @app.fastapi_app.get("/info")
665
- async def custom_api_info():
666
- """Custom API info endpoint with error handling"""
667
- return JSONResponse(content={
668
- "error": "API schema generation disabled",
669
- "message": "Use the Gradio UI for direct interaction"
670
- })
671
-
672
  app.launch(
673
  server_name="0.0.0.0",
674
  server_port=7860,
675
  share=False,
676
  show_error=True
677
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
678
  except Exception as e:
679
  logger.error(f"Failed to launch app: {e}")
680
  import traceback
 
658
  # Create and launch app
659
  app = create_ui()
660
 
661
+ # Launch with API mode disabled to prevent JSON schema errors
 
 
 
 
 
 
 
 
 
 
662
  app.launch(
663
  server_name="0.0.0.0",
664
  server_port=7860,
665
  share=False,
666
  show_error=True
667
  )
668
+
669
+ # Override /info endpoint after launch to prevent JSON schema errors
670
+ try:
671
+ from fastapi.responses import JSONResponse
672
+
673
+ @app.app.get("/info")
674
+ async def custom_api_info():
675
+ """Custom API info endpoint with error handling"""
676
+ return JSONResponse(content={
677
+ "error": "API schema generation disabled",
678
+ "message": "Use the Gradio UI for direct interaction"
679
+ })
680
+ except Exception as e:
681
+ logger.warning(f"Could not override /info endpoint: {e}")
682
  except Exception as e:
683
  logger.error(f"Failed to launch app: {e}")
684
  import traceback