File size: 838 Bytes
d1a66a2
 
06f7537
d1a66a2
edb525a
d1a66a2
06f7537
d1a66a2
06f7537
d1a66a2
 
edb525a
 
 
 
 
 
1a6f950
 
 
d1a66a2
9004d37
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
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
    access_token or aiohttp.web.HTTPUnauthorized(text="Access token is missing or invalid")
    
    # 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 ,brand_name, websocket)