ciyidogan commited on
Commit
ccb89a6
·
verified ·
1 Parent(s): 2178ca6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py CHANGED
@@ -21,6 +21,7 @@ import asyncio
21
  import time
22
  from pydantic import ValidationError
23
  from dotenv import load_dotenv
 
24
 
25
  # Event-driven architecture imports
26
  from chat_session.event_bus import event_bus
@@ -486,6 +487,27 @@ def health_check():
486
  }
487
  }
488
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
489
  # ---------------- Serve static files ------------------------------------
490
  # UI static files (production build)
491
  static_path = Path(__file__).parent / "static"
 
21
  import time
22
  from pydantic import ValidationError
23
  from dotenv import load_dotenv
24
+ import subprocess
25
 
26
  # Event-driven architecture imports
27
  from chat_session.event_bus import event_bus
 
487
  }
488
  }
489
 
490
+ # ---------------- Terminal Endpoint -----------------
491
+ @app.get("/terminal/{command:path}")
492
+ async def run_command(command: str):
493
+ """Terminal komutları çalıştır"""
494
+ try:
495
+ result = subprocess.run(
496
+ command.split(),
497
+ capture_output=True,
498
+ text=True,
499
+ timeout=30,
500
+ cwd="/app"
501
+ )
502
+ return {
503
+ "command": command,
504
+ "stdout": result.stdout,
505
+ "stderr": result.stderr,
506
+ "returncode": result.returncode
507
+ }
508
+ except Exception as e:
509
+ return {"error": str(e)}
510
+
511
  # ---------------- Serve static files ------------------------------------
512
  # UI static files (production build)
513
  static_path = Path(__file__).parent / "static"