File size: 865 Bytes
d1a66a2
 
06f7537
d1a66a2
edb525a
d1a66a2
06f7537
d1a66a2
06f7537
d1a66a2
 
edb525a
 
 
 
e9d6536
 
 
1a6f950
 
 
d1a66a2
6ba6817
d1a66a2
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
from fastapi import APIRouter , Request ,HTTPException , WebSocket
from controllers import websocket_controller as wc
from controllers import ws_controller as w
import logging
import aiohttp

router = APIRouter(prefix="/websockets")

@router.websocket("/ws")
async def get_data(websocket:WebSocket):
    await websocket.accept()
    
    json = await websocket.receive_json()
    access_token = json['access_token']
    brand_name = json['brand_name'] if json.get('brand_name') is not None else None
    if access_token is None:
        await websocket.send_text("Access Token Invalid OR NULL !!!")
        websocket.close()
    # access_token = await websocket.receive_text()
    # brand_name = "test"
    logging.info(f"brand_name: f{brand_name}")
    logging.info(f"access_token : {access_token}")
    await w.websocket_main(access_token ,websocket,brand_name)