ashishkblink commited on
Commit
c5008c7
·
verified ·
1 Parent(s): 5b2e5f5

Update pipe_method3.py

Browse files
Files changed (1) hide show
  1. pipe_method3.py +4 -4
pipe_method3.py CHANGED
@@ -292,19 +292,19 @@ async def twilio_keepalive(ws: WebSocket, st: CallState):
292
  async def health():
293
  return {"ok": True}
294
 
295
- @app.post("/voice")
296
  async def voice(request: Request):
297
  stream_url = TWILIO_STREAM_URL
298
  if not stream_url:
299
  host = request.headers.get("host")
300
  if host:
301
- stream_url = f"wss://{host}/stream"
302
  P("SYS>", f"auto_stream_url={stream_url}")
303
  if not stream_url:
304
  return PlainTextResponse("TWILIO_STREAM_URL not set and host not found", status_code=500)
305
  return Response(content=build_twiml(stream_url), media_type="application/xml")
306
 
307
- @app.get("/voice")
308
  async def voice_get(request: Request):
309
  return await voice(request)
310
 
@@ -316,7 +316,7 @@ async def debug_last():
316
  # ----------------------------
317
  # WebSocket /stream
318
  # ----------------------------
319
- @app.websocket("/stream")
320
  async def stream(ws: WebSocket):
321
  await ws.accept()
322
  st = CallState(call_id=str(id(ws)))
 
292
  async def health():
293
  return {"ok": True}
294
 
295
+ @app.post("/twilio/voice")
296
  async def voice(request: Request):
297
  stream_url = TWILIO_STREAM_URL
298
  if not stream_url:
299
  host = request.headers.get("host")
300
  if host:
301
+ stream_url = f"wss://{host}/twilio/stream"
302
  P("SYS>", f"auto_stream_url={stream_url}")
303
  if not stream_url:
304
  return PlainTextResponse("TWILIO_STREAM_URL not set and host not found", status_code=500)
305
  return Response(content=build_twiml(stream_url), media_type="application/xml")
306
 
307
+ @app.get("/twilio/voice")
308
  async def voice_get(request: Request):
309
  return await voice(request)
310
 
 
316
  # ----------------------------
317
  # WebSocket /stream
318
  # ----------------------------
319
+ @app.websocket("/twilio/stream")
320
  async def stream(ws: WebSocket):
321
  await ws.accept()
322
  st = CallState(call_id=str(id(ws)))