main.py 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713
  1. import xml.etree.ElementTree as ET
  2. from typing import Union
  3. from fastapi import FastAPI
  4. import os
  5. import uuid
  6. import re
  7. import zipfile
  8. import json
  9. from fastapi.middleware.cors import CORSMiddleware
  10. from fastapi.middleware.gzip import GZipMiddleware
  11. import base64
  12. from pydantic import BaseModel
  13. from subdir import service
  14. from subdir import db
  15. from subdir import util
  16. import numpy as np
  17. from fastapi.staticfiles import StaticFiles
  18. from pymongo import AsyncMongoClient
  19. client = AsyncMongoClient()
  20. from fastapi.responses import FileResponse
  21. from fastapi import WebSocket, WebSocketDisconnect
  22. from fastapi import UploadFile
  23. class ConnectionManager:
  24. """Class defining socket events"""
  25. def __init__(self):
  26. """init method, keeping track of connections"""
  27. self.active_connections = []
  28. async def connect(self, websocket: WebSocket):
  29. """connect event"""
  30. await websocket.accept()
  31. self.active_connections.append(websocket)
  32. async def send_personal_message(self, message: str, websocket: WebSocket):
  33. """Direct Message"""
  34. await websocket.send_text(message)
  35. def disconnect(self, websocket: WebSocket):
  36. """disconnect event"""
  37. self.active_connections.remove(websocket)
  38. app = FastAPI()
  39. origins = [
  40. "http://localhost.tiangolo.com",
  41. "https://localhost.tiangolo.com",
  42. "http://localhost",
  43. "http://localhost:9002",
  44. "http://127.0.0.1:9002",
  45. ]
  46. app.add_middleware(
  47. CORSMiddleware,
  48. allow_origins=["*"],
  49. allow_credentials=True,
  50. allow_methods=["*"],
  51. allow_headers=["*"],
  52. )
  53. app.add_middleware(GZipMiddleware, minimum_size=1000, compresslevel=5)
  54. app.mount("/static", StaticFiles(directory="front/dist"), name="static")
  55. manager = ConnectionManager()
  56. for root, dirs, files in os.walk("./data", topdown=False):
  57. for name in files:
  58. print(os.path.join(root, name))
  59. file_data = os.path.join(root, name)
  60. def getDetail(root):
  61. print(root.tag)
  62. print(root.text)
  63. print(root.attrib)
  64. result = []
  65. result.append(["名称", "金额", "暂估价", "安全文明施工费", "规费"])
  66. for child in root:
  67. print(child.tag)
  68. print(child.attrib)
  69. if child.tag == "TouBiaoXx":
  70. result.append([child.attrib["Zbr"], child.attrib["Tbzj"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  71. if child.tag == "Dxgcxx":
  72. Dxgcbh = child.attrib["Dxgcbh"]
  73. Dxgcmc = child.attrib["Dxgcmc"]
  74. result.append([child.attrib["Dxgcmc"], child.attrib["Je"], child.attrib["Zgj"], child.attrib["Aqwmf"], child.attrib["Gf"]])
  75. return result
  76. def getOutline(root):
  77. print(root.tag)
  78. print(root.text)
  79. print(root.attrib)
  80. result = []
  81. for child in root:
  82. print(child.tag)
  83. print(child.attrib)
  84. if child.tag == "TouBiaoXx":
  85. result.append({"id" : "TouBiaoXx", "label" : "投标信息" })
  86. if child.tag == "Dxgcxx":
  87. Dxgcbh = child.attrib["Dxgcbh"]
  88. Dxgcmc = child.attrib["Dxgcmc"]
  89. result2 = []
  90. for child1 in child:
  91. #print("level2===================================")
  92. #print(child1.tag)
  93. #print(child1.attrib)
  94. Dwgcbh = child1.attrib["Dwgcbh"]
  95. Dwgcmc = child1.attrib["Dwgcmc"]
  96. Zylb = child1.attrib["Zylb"]
  97. result2.append({"id" : Dwgcbh,"Zylb":Zylb, "label": Dwgcmc, "children" : service.getDwgc(root, Dwgcbh, Zylb)})
  98. result.append({"id" : Dxgcbh, "label" : Dxgcmc, "children" : result2})
  99. return result
  100. class Info(BaseModel):
  101. name: str
  102. class DingeshuRequest(BaseModel):
  103. value: int
  104. class DingeXilieRequest(BaseModel):
  105. value: int
  106. id: str
  107. class SingleDingeXilieRequest(BaseModel):
  108. zhuanye: int
  109. debh: str
  110. class InfoWithID(BaseModel):
  111. name: str
  112. id: str
  113. class Tiaojia(BaseModel):
  114. biao_id: str
  115. bh: str
  116. bm: str
  117. mingcheng: str
  118. danwei: str
  119. jiage: str
  120. glf: str
  121. lr: str
  122. bz: int
  123. class SearchDe(BaseModel):
  124. zhuanye: str
  125. text: str
  126. class UpdateZjcs(BaseModel):
  127. biao_id: str
  128. bh: str
  129. mc: str
  130. fl: str
  131. @app.post("/outline")
  132. async def read_root(info: Info):
  133. for root, dirs, files in os.walk("./data", topdown=False):
  134. for name in files:
  135. if name == info.name:
  136. print(os.path.join(root, name))
  137. file_data = os.path.join(root, name)
  138. tree = ET.parse(file_data)
  139. root = tree.getroot()
  140. return getOutline(root)
  141. @app.post("/outline2")
  142. async def read_root2(info: Info):
  143. return await db.getOutline(client, info.name)
  144. @app.post("/detail")
  145. async def read_detail(info: Info):
  146. for root, dirs, files in os.walk("./data", topdown=False):
  147. for name in files:
  148. if name == info.name:
  149. print(os.path.join(root, name))
  150. file_data = os.path.join(root, name)
  151. tree = ET.parse(file_data)
  152. root = tree.getroot()
  153. return getDetail(root)
  154. @app.post("/detail2")
  155. async def read_detail2(info: Info):
  156. return await db.getDetail(client, info.name)
  157. @app.post("/baojiahuizong/")
  158. async def read_bjhz(info: InfoWithID):
  159. for root, dirs, files in os.walk("./data", topdown=False):
  160. for name in files:
  161. if name == info.name:
  162. print(os.path.join(root, name))
  163. file_data = os.path.join(root, name)
  164. tree = ET.parse(file_data)
  165. root = tree.getroot()
  166. return service.getBjhz(root, info.id)
  167. @app.post("/baojiahuizong2/")
  168. async def read_bjhz2(info: InfoWithID):
  169. raw = await db.getBjhz(client, info.name, info.id)
  170. raw2 = []
  171. for entry in raw:
  172. if "__children" in entry:
  173. entry["_children"] = entry["__children"]
  174. for grandchild in entry["_children"]:
  175. if "__children" in grandchild:
  176. grandchild['_children'] = grandchild['__children']
  177. del grandchild['__children']
  178. del entry["__children"]
  179. raw2.append(entry)
  180. return raw2
  181. @app.post("/guifeishuijin/")
  182. async def read_gfsj(info: InfoWithID):
  183. for root, dirs, files in os.walk("./data", topdown=False):
  184. for name in files:
  185. if name == info.name:
  186. print(os.path.join(root, name))
  187. file_data = os.path.join(root, name)
  188. tree = ET.parse(file_data)
  189. root = tree.getroot()
  190. return service.getGfsj(root, info.id)
  191. @app.post("/guifeishuijin2/")
  192. async def read_gfsj2(info: InfoWithID):
  193. raw = await db.getGfsj(client, info.name, info.id)
  194. raw2 = []
  195. for entry in raw:
  196. if "__children" in entry:
  197. entry["_children"] = entry["__children"]
  198. del entry["__children"]
  199. raw2.append(entry)
  200. return raw2
  201. @app.post("/qitaxiangmu/")
  202. async def read_qtxm(info: InfoWithID):
  203. for root, dirs, files in os.walk("./data", topdown=False):
  204. for name in files:
  205. if name == info.name:
  206. print(os.path.join(root, name))
  207. file_data = os.path.join(root, name)
  208. tree = ET.parse(file_data)
  209. root = tree.getroot()
  210. return service.getQtxm(root, info.id)
  211. @app.post("/qitaxiangmu2/")
  212. async def read_qtxm2(info: InfoWithID):
  213. raw = await db.getQtxm(client, info.name, info.id)
  214. raw2 = []
  215. for entry in raw:
  216. if "__children" in entry:
  217. entry["_children"] = entry["__children"]
  218. del entry["__children"]
  219. raw2.append(entry)
  220. return raw2
  221. @app.post("/zygczgj/")
  222. async def zygczgj(info: InfoWithID):
  223. return await db.getZygczgj(client, info.name, info.id)
  224. @app.post("/zanliejine/")
  225. async def read_zlje(info: InfoWithID):
  226. for root, dirs, files in os.walk("./data", topdown=False):
  227. for name in files:
  228. if name == info.name:
  229. print(os.path.join(root, name))
  230. file_data = os.path.join(root, name)
  231. tree = ET.parse(file_data)
  232. root = tree.getroot()
  233. return service.getZlje(root, info.id)
  234. @app.post("/zanliejine2/")
  235. async def read_zlje2(info: InfoWithID):
  236. return await db.getZlje(client, info.name, info.id)
  237. @app.post("/jirigong/")
  238. async def read_jrg(info: InfoWithID):
  239. for root, dirs, files in os.walk("./data", topdown=False):
  240. for name in files:
  241. if name == info.name:
  242. print(os.path.join(root, name))
  243. file_data = os.path.join(root, name)
  244. tree = ET.parse(file_data)
  245. root = tree.getroot()
  246. return service.getJrg(root, info.id)
  247. @app.post("/jirigong2/")
  248. async def read_jrg2(info: InfoWithID):
  249. return await db.getJrg(client, info.name, info.id)
  250. @app.post("/zongchengbaofuwufei/")
  251. async def read_zcbfwf(info: InfoWithID):
  252. for root, dirs, files in os.walk("./data", topdown=False):
  253. for name in files:
  254. if name == info.name:
  255. print(os.path.join(root, name))
  256. file_data = os.path.join(root, name)
  257. tree = ET.parse(file_data)
  258. root = tree.getroot()
  259. return service.getZcbfwf(root, info.id)
  260. @app.post("/zongchengbaofuwufei2/")
  261. async def read_zcbfwf2(info: InfoWithID):
  262. return await db.getZcbfwf(client, info.name, info.id)
  263. @app.post("/fabaorengongyingcailiao/")
  264. async def read_fbrgycl(info: InfoWithID):
  265. for root, dirs, files in os.walk("./data", topdown=False):
  266. for name in files:
  267. if name == info.name:
  268. print(os.path.join(root, name))
  269. file_data = os.path.join(root, name)
  270. tree = ET.parse(file_data)
  271. root = tree.getroot()
  272. return service.getFbrgycl(root, info.id)
  273. @app.post("/fabaorengongyingcailiao2/")
  274. async def read_fbrgycl2(info: InfoWithID):
  275. return await db.getFbrgycl(client, info.name, info.id)
  276. @app.post("/rencaijihuizong/")
  277. async def read_rcjhz(info: InfoWithID):
  278. for root, dirs, files in os.walk("./data", topdown=False):
  279. for name in files:
  280. if name == info.name:
  281. print(os.path.join(root, name))
  282. file_data = os.path.join(root, name)
  283. tree = ET.parse(file_data)
  284. root = tree.getroot()
  285. return service.getRcjhz(root, info.id)
  286. @app.post("/rencaijihuizong2/")
  287. async def read_rcjhz2(info: InfoWithID):
  288. return await db.getRcjhz(client, info.name, info.id)
  289. @app.post("/qingdanxiangmu/")
  290. async def read_qdxm(info: InfoWithID):
  291. for root, dirs, files in os.walk("./data", topdown=False):
  292. for name in files:
  293. if name == info.name:
  294. print(os.path.join(root, name))
  295. file_data = os.path.join(root, name)
  296. tree = ET.parse(file_data)
  297. root = tree.getroot()
  298. return service.getQdxm(root, info.id)
  299. #return []
  300. @app.post("/qingdanxiangmu2/")
  301. async def read_qdxm2(info: InfoWithID):
  302. return await db.getQdxm(client, info.name, info.id)
  303. class Item(BaseModel):
  304. bh: str
  305. bt: str
  306. name: str
  307. class Rcj(BaseModel):
  308. bh: str
  309. bt: str
  310. bm: str
  311. name: str
  312. class Dercj(BaseModel):
  313. bh: str
  314. bt: str
  315. qdbm: str
  316. debm: str
  317. name: str
  318. class Zjcs(BaseModel):
  319. bh: str
  320. name: str
  321. @app.post("/qingdanmingxi/")
  322. async def read_qdmx(item : Item):
  323. return await db.getQdmx(client, item.name, item.bh, item.bt)
  324. @app.post("/qingdanrcj/")
  325. async def read_rcj(item : Rcj):
  326. if item.bt == "Djcs":
  327. return await db.getDjcsQingdanrcj(client, item.name, item.bh, item.bt, item.bm)
  328. return await db.getQingdanrcj(client, item.name, item.bh, item.bt, item.bm)
  329. @app.post("/qingdantuijian/")
  330. async def read_tuijian(item : Rcj):
  331. return service.getQingdanTuijian(item.bh, item.bt, item.bm)
  332. @app.post("/dingercj/")
  333. async def read_dercj(item : Dercj):
  334. if item.bt == "Djcs":
  335. return await db.getDjcsDingercj(client, item.name, item.bh, item.bt, item.qdbm, item.debm)
  336. return await db.getDingercj(client, item.name, item.bh, item.bt, item.qdbm, item.debm)
  337. @app.post("/zjcs/")
  338. async def read_zjcs(item : Zjcs):
  339. raw = await db.getZjcs(client, item.name, item.bh)
  340. raw2 = []
  341. for entry in raw:
  342. if "__children" in entry:
  343. entry["_children"] = entry["__children"]
  344. del entry["__children"]
  345. raw2.append(entry)
  346. return raw2
  347. @app.post("/djcs/")
  348. async def read_djcs(item : Zjcs):
  349. raw = await db.getDjcs(client, item.name, item.bh)
  350. raw2 = []
  351. for entry in raw:
  352. if "__children" in entry:
  353. entry["_children"] = entry["__children"]
  354. del entry["__children"]
  355. raw2.append(entry)
  356. return raw2
  357. @app.post("/files/")
  358. async def read_files():
  359. result = []
  360. for root, dirs, files in os.walk("./data", topdown=False):
  361. for name in files:
  362. print(os.path.join(root, name))
  363. result.append([name, "", ""])
  364. return result
  365. @app.post("/files2/")
  366. async def read_files2():
  367. result = await db.list_files(client)
  368. return result
  369. @app.post("/deleteFile/")
  370. async def delete(r: Info):
  371. result = await db.delete_files(client, r.name)
  372. return result
  373. @app.post("/des/")
  374. async def read_des(r: DingeshuRequest):
  375. result = service.getDes(r.value)
  376. #print(result)
  377. return result
  378. @app.post("/pbs/")
  379. async def read_pbs(r: DingeshuRequest):
  380. result = service.getPbs(r.value)
  381. #print(result)
  382. result.insert(0, {"id": "0", "label": "全部"})
  383. return result
  384. @app.post("/pbxl/")
  385. async def read_pbxl(r: Info):
  386. result = service.getPbxl(r.name)
  387. #print(result)
  388. return result
  389. @app.post("/cankao/")
  390. async def cankao():
  391. result = service.getCankao()
  392. #print(result)
  393. return result
  394. @app.post("/qufei/")
  395. async def read_qufei(r: Info):
  396. return await db.getQufei(client, r.name)
  397. @app.post("/dexilie/")
  398. async def read_dexilie(r: DingeXilieRequest):
  399. result = service.getDeXilie(r.value, r.id)
  400. #print(result)
  401. return result
  402. @app.post("/singledexilie/")
  403. async def read_singledexilie(r: SingleDingeXilieRequest):
  404. if r.debh.startswith("D") :
  405. return json.dumps({
  406. "reverse": "None",
  407. "rgde": None,
  408. "jxde": None,
  409. "clde": None,
  410. "actual_zhuanye": r.zhuanye,
  411. "bz_selected": {"BZBH": {}},
  412. "bz_selected2": {"BZBH": {}}
  413. }, ensure_ascii=False)
  414. result1, result2, rgde, jxde, clde, bz_selected, bz_selected2, actual_zhuanye= service.getSingleDeXilie(r.zhuanye, r.debh)
  415. print("get result ***************************************")
  416. if result1:
  417. result3 = json.loads(result1)
  418. else:
  419. result3 = {}
  420. result3["reverse"] = str(result2)
  421. result3["rgde"] = rgde
  422. result3["jxde"] = jxde
  423. result3["clde"] = clde
  424. result3["actual_zhuanye"] = actual_zhuanye
  425. if bz_selected != None:
  426. result3["bz_selected"] = json.loads(bz_selected)
  427. else:
  428. result3["bz_selected"] = {"BZBH": {}}
  429. if bz_selected2 != None:
  430. result3["bz_selected2"] = json.loads(bz_selected2)
  431. else:
  432. result3["bz_selected2"] = {"BZBH": {}}
  433. if "[" in r.debh:
  434. position3 = r.debh.find("*")
  435. coef = 1
  436. if position3 == -1:
  437. pass
  438. else:
  439. coef = r.debh[1 + position3:]
  440. print(coef)
  441. tail = 0
  442. for i in range(0, len(coef) + 1):
  443. if i == len(coef):
  444. tail = i
  445. break
  446. if coef[i] > '9' or coef[i] < '0':
  447. tail = i
  448. break
  449. if tail == 0:
  450. print("1113111")
  451. result3["reverse"] = 'None'
  452. return json.dumps(result3, ensure_ascii=False)
  453. coef = int(coef[0:tail])
  454. position1 = r.debh.find("[")
  455. position2 = r.debh.find("]")
  456. if position2 == -1:
  457. print("1121111")
  458. result3["reverse"] = 'None'
  459. return json.dumps(result3, ensure_ascii=False)
  460. if r.debh[position1-1] == "+":
  461. pass
  462. elif r.debh[position1-1] == "-":
  463. coef = -coef
  464. else:
  465. print("111111")
  466. result3["reverse"] = 'None'
  467. return json.dumps(result3, ensure_ascii=False)
  468. debh = r.debh[position1+1: position2]
  469. if result3['GLDE']:
  470. hit = False
  471. for key, value in result3['GLDE'].items():
  472. if value == debh:
  473. hit = True
  474. if not hit:
  475. result3["reverse"] = 'None'
  476. return json.dumps(result3, ensure_ascii=False)
  477. else:
  478. result3["reverse"] = 'None'
  479. return json.dumps(result3, ensure_ascii=False)
  480. result1_, result2_, rgde_, jxde_, clde_, bz_selected_, bz_selected2_, actual_zhuanye_ = service.getSingleDeXilie(r.zhuanye, debh)
  481. if result1_:
  482. util.mergerg(rgde, rgde_, coef)
  483. util.mergejx(jxde, jxde_, coef)
  484. util.mergecl(clde, clde_, coef)
  485. result3["rgde"] = rgde
  486. result3["jxde"] = jxde
  487. result3["clde"] = clde
  488. item_ = None
  489. for item in result3['DW'].keys():
  490. item_ = item
  491. result3['DEBH'] = {item_: util.cleanBM(r.debh)}
  492. else:
  493. result3["reverse"] = 'None'
  494. return json.dumps(result3, ensure_ascii=False)
  495. @app.post("/save/")
  496. async def save(r: Info):
  497. data = json.loads(r.name)
  498. print(data)
  499. return await db.save(client, data)
  500. @app.post("/savedjcs/")
  501. async def savedjcs(r: Info):
  502. data = json.loads(r.name)
  503. print(data)
  504. return await db.savedjcs(client, data)
  505. @app.post("/applyFL/")
  506. async def applyFL(r: InfoWithID):
  507. data = json.loads(r.name)
  508. print(data)
  509. return await db.applyFL(client, r.id, data)
  510. @app.post("/tiaojia/")
  511. async def tiaojia(r: Tiaojia):
  512. ##return []
  513. glf = r.glf
  514. lr = r.lr
  515. if r.glf == '':
  516. glf = '0'
  517. if r.lr == "":
  518. lr = '0'
  519. return await db.tiaojia(client, r.biao_id, r.bh, r.bm, r.mingcheng, r.danwei, r.jiage, glf, lr, r.bz)
  520. @app.post("/searchde/")
  521. async def searchde(r: SearchDe):
  522. ##return []
  523. return await db.searchde(client, r.zhuanye, r.text)
  524. @app.post("/updatezjcs/")
  525. async def updatezjcs(r: UpdateZjcs):
  526. ##return []
  527. return await db.updatezjcs(client, r.biao_id, r.bh, r.mc, r.fl)
  528. @app.post("/upload/")
  529. async def upload(file: UploadFile):
  530. if file.filename.endswith('13jz') or file.filename.endswith("13jt"):
  531. content = await file.read()
  532. string = content.decode('utf-8')
  533. await resolve(string)
  534. return [file.filename]
  535. elif file.filename.endswith("jszf"):
  536. content = await file.read()
  537. string = content.decode('utf-8')
  538. root = ET.fromstring(string)
  539. for child in root:
  540. print(child)
  541. if child.tag == "ZBFileContent":
  542. base64_bytes = child.text.encode("ascii")
  543. sample_string_bytes = base64.b64decode(base64_bytes)
  544. tmp = str(uuid.uuid4())
  545. os.mkdir(os.path.join("tmp", tmp))
  546. with open(tmp, "wb") as file_:
  547. file_.write(sample_string_bytes)
  548. with zipfile.ZipFile(tmp, 'r') as zip_ref:
  549. zip_ref.extractall(os.path.join("tmp", tmp))
  550. dir_list = os.listdir(os.path.join("tmp", tmp))
  551. print(dir_list)
  552. for entry in dir_list:
  553. if entry.endswith("13jz"):
  554. with open(os.path.join("tmp", tmp, entry), 'r') as f:
  555. await resolve(f.read())
  556. return [file.filename]
  557. else:
  558. return [file.filename]
  559. @app.get("/download/{item_id}")
  560. async def download_file(item_id):
  561. file_path = "export/contacts.xml"
  562. # Create the root element
  563. root = ET.Element("JingJiBiao")
  564. # Create a sub-element
  565. ##TouBiaoXx = ET.SubElement(root, "TouBiaoXx")
  566. await db.build(client, root, item_id)
  567. # Create the tree and write to a file
  568. tree = ET.ElementTree(root)
  569. tree.write("export/contacts.xml", xml_declaration=True, encoding="UTF-8")
  570. return FileResponse(file_path, media_type='application/octet-stream', filename="contacts.xml")
  571. async def resolve(data):
  572. await db.resolve(data, client)##manager.send_personal_message(f"You wrote: {data}", websocket)
  573. @app.websocket("/ws")
  574. async def websocket_endpoint(websocket: WebSocket):
  575. await manager.connect(websocket)
  576. try:
  577. while True:
  578. data = await websocket.receive_text()
  579. await resolve(websocket, data)
  580. ##await manager.broadcast(f"Client #{client_id} says: {data}")
  581. except WebSocketDisconnect:
  582. manager.disconnect(websocket)
  583. ##await manager.broadcast(f"Client left the chat")