forked from EDEAI/NexusAI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
websocket.py
31 lines (25 loc) · 833 Bytes
/
websocket.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import uvicorn
import asyncio
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from config import settings
from core.websocket.websocket_manager import websocket_router
from core.websocket.websocket_queue_pop import queue_processor
app = FastAPI(
title="NexusAI WebSocket Server",
description="WebSocket server for handling real-time connections.",
version="1.0.0"
)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
app.include_router(websocket_router())
def start_queue_processor():
asyncio.create_task(queue_processor())
app.add_event_handler("startup", start_queue_processor)
if __name__ == "__main__":
uvicorn.run("websocket:app", host="0.0.0.0", port=settings.WEBSOCKET_PORT)