Really-amin commited on
Commit
41e4589
·
verified ·
1 Parent(s): c66ea20

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -0
app.py CHANGED
@@ -114,6 +114,14 @@ async def startup_event():
114
  # شروع broadcast task
115
  asyncio.create_task(broadcast_stats())
116
  logger.info("✅ Background tasks started")
 
 
 
 
 
 
 
 
117
 
118
  # Helper functions
119
  def get_stats_data():
@@ -689,6 +697,27 @@ async def websocket_endpoint(websocket: WebSocket):
689
  logger.error(f"WebSocket error: {e}")
690
  manager.disconnect(websocket)
691
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
692
  # Run with uvicorn
693
  if __name__ == "__main__":
694
  import uvicorn
 
114
  # شروع broadcast task
115
  asyncio.create_task(broadcast_stats())
116
  logger.info("✅ Background tasks started")
117
+
118
+ # شروع background agents
119
+ try:
120
+ from background_agents import start_agents
121
+ await start_agents()
122
+ logger.info("✅ Background agents started")
123
+ except Exception as e:
124
+ logger.error(f"Failed to start background agents: {e}")
125
 
126
  # Helper functions
127
  def get_stats_data():
 
697
  logger.error(f"WebSocket error: {e}")
698
  manager.disconnect(websocket)
699
 
700
+ # Include additional API endpoints
701
+ try:
702
+ from api_endpoints import router as api_router
703
+ app.include_router(api_router)
704
+ logger.info("✅ Additional API endpoints loaded")
705
+ except Exception as e:
706
+ logger.error(f"Failed to load API endpoints: {e}")
707
+
708
+ # Agents status endpoint
709
+ @app.get("/api/agents/status")
710
+ async def get_agents_status():
711
+ """وضعیت background agents"""
712
+ try:
713
+ from background_agents import get_agents_status
714
+ return get_agents_status()
715
+ except Exception as e:
716
+ return {
717
+ "error": str(e),
718
+ "timestamp": datetime.now().isoformat()
719
+ }
720
+
721
  # Run with uvicorn
722
  if __name__ == "__main__":
723
  import uvicorn