33 lines
826 B
Python
33 lines
826 B
Python
from __future__ import annotations
|
|
|
|
import argparse
|
|
import asyncio
|
|
|
|
from aiohttp import web
|
|
|
|
|
|
async def websocket_handler(request: web.Request) -> web.WebSocketResponse:
|
|
ws = web.WebSocketResponse()
|
|
await ws.prepare(request)
|
|
await asyncio.sleep(3600)
|
|
return ws
|
|
|
|
|
|
def parse_args() -> argparse.Namespace:
|
|
parser = argparse.ArgumentParser(
|
|
description="WebSocket stub that accepts connections but sends no STATUS."
|
|
)
|
|
parser.add_argument("--host", default="127.0.0.1")
|
|
parser.add_argument("--port", type=int, default=8000)
|
|
return parser.parse_args()
|
|
|
|
|
|
def main() -> None:
|
|
args = parse_args()
|
|
app = web.Application()
|
|
app.router.add_get("/v1/agent_ws/{chat_id}/", websocket_handler)
|
|
web.run_app(app, host=args.host, port=args.port)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|