klentyboopathi commited on
Commit
05340a0
·
1 Parent(s): f0543f3
Files changed (1) hide show
  1. server.py +15 -1
server.py CHANGED
@@ -51,9 +51,23 @@ async def websocket_endpoint(websocket: WebSocket):
51
  print(f"Exception in run_bot: {e}")
52
 
53
 
 
 
 
 
 
 
 
 
 
 
54
  @app.post("/connect")
55
  async def bot_connect(request: Request) -> Dict[Any, Any]:
56
- return {"ws_url": "ws://localhost:7860/ws"}
 
 
 
 
57
 
58
 
59
  async def main():
 
51
  print(f"Exception in run_bot: {e}")
52
 
53
 
54
+ @app.get("/")
55
+ async def read_root():
56
+ """Root endpoint that provides basic information about the API."""
57
+ return {
58
+ "message": "VoiceStack API is running",
59
+ "status": "online",
60
+ "endpoints": {"websocket": "/ws", "connect": "/connect"},
61
+ }
62
+
63
+
64
  @app.post("/connect")
65
  async def bot_connect(request: Request) -> Dict[Any, Any]:
66
+ # return {"ws_url": "ws://localhost:7860/ws"}
67
+ # Get the host from the request headers for dynamic URL generation
68
+ host = request.headers.get("host", "localhost:7860")
69
+ protocol = "wss" if request.url.scheme == "https" else "ws"
70
+ return {"ws_url": f"{protocol}://{host}/ws"}
71
 
72
 
73
  async def main():