rahul7star commited on
Commit
0433883
·
verified ·
1 Parent(s): 4fd24a4

Update flux_train_ui.py

Browse files
Files changed (1) hide show
  1. flux_train_ui.py +3 -12
flux_train_ui.py CHANGED
@@ -466,18 +466,9 @@ def train_model_ui(data: str):
466
 
467
  # ⬇️ DO NOT remove this since you're keeping the manual launch
468
  if __name__ == "__main__":
469
- # Unpack launch return value if it's a tuple
470
- result = demo.launch(share=True, show_error=True, prevent_thread_lock=True)
471
 
472
- if isinstance(result, tuple):
473
- server = result[0]
474
- else:
475
- server = result
476
-
477
- # Try to get the FastAPI app object
478
- fastapi_app = getattr(server, "app", None) or getattr(server, "server", None).app
479
-
480
- @fastapi_app.post("/trigger")
481
  async def trigger(request: Request):
482
  try:
483
  body = await request.json()
@@ -487,7 +478,7 @@ if __name__ == "__main__":
487
  except Exception as e:
488
  return {"error": str(e)}
489
 
490
- server.block_thread()
491
 
492
 
493
 
 
466
 
467
  # ⬇️ DO NOT remove this since you're keeping the manual launch
468
  if __name__ == "__main__":
469
+ app = demo.launch(share=True, show_error=True, prevent_thread_lock=True)
 
470
 
471
+ @app.post("/trigger")
 
 
 
 
 
 
 
 
472
  async def trigger(request: Request):
473
  try:
474
  body = await request.json()
 
478
  except Exception as e:
479
  return {"error": str(e)}
480
 
481
+ app.block() # keep the server running
482
 
483
 
484