Spaces:
Runtime error
Runtime error
CaesarCloudSync
commited on
Commit
·
4be6e8d
1
Parent(s):
0a6d947
getrevisioncardsws maybe connection works
Browse files- __pycache__/main.cpython-310.pyc +0 -0
- main.py +25 -26
- requirements.txt +1 -1
__pycache__/main.cpython-310.pyc
CHANGED
Binary files a/__pycache__/main.cpython-310.pyc and b/__pycache__/main.cpython-310.pyc differ
|
|
main.py
CHANGED
@@ -21,6 +21,7 @@ from datetime import datetime
|
|
21 |
from PIL import Image, ImageOps
|
22 |
from io import BytesIO
|
23 |
import base64
|
|
|
24 |
import json
|
25 |
import stripe
|
26 |
import jwt
|
@@ -411,33 +412,31 @@ async def getrevisioncardsws(websocket: WebSocket):
|
|
411 |
|
412 |
try:
|
413 |
while True:
|
414 |
-
authinfo = await websocket.receive_json()
|
415 |
-
authorization = authinfo["headers"]["Authorization"]
|
416 |
-
current_user = secure_decode(authorization.replace("Bearer ",""))["email"]
|
417 |
-
if current_user:
|
418 |
-
try:
|
419 |
-
email_exists = importcsv.db.accountrevisioncards.find_one({"email":current_user})
|
420 |
-
if email_exists: # Checks if email exists
|
421 |
-
user_revision_cards = list(importcsv.db.accountrevisioncards.find({"email": current_user}))[0]
|
422 |
-
del user_revision_cards["_id"],user_revision_cards["email"]
|
423 |
-
#return StreamingResponse(iter_df(user_revision_cards), media_type="application/json")
|
424 |
-
#return user_revision_cards
|
425 |
-
for revisioncard in user_revision_cards["revisioncards"]:
|
426 |
-
revisioncard.update({"revisionscheduleinterval":user_revision_cards["revisionscheduleinterval"],"sendtoemail":user_revision_cards["sendtoemail"]})
|
427 |
-
await websocket.send_json(json.dumps(revisioncard)) # sends the buffer as bytes
|
428 |
-
elif not email_exists:
|
429 |
-
await websocket.send_json(json.dumps({"message":"No revision cards"}))
|
430 |
-
#return {"message":"No revision cards"} # Send in shape of data
|
431 |
-
except Exception as ex:
|
432 |
-
return {f"error":f"{type(ex)},{str(ex)}"}
|
433 |
-
elif not current_user:
|
434 |
-
await websocket.send_json(json.dumps({"message":"No user."}))
|
435 |
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
441 |
|
442 |
|
443 |
|
|
|
21 |
from PIL import Image, ImageOps
|
22 |
from io import BytesIO
|
23 |
import base64
|
24 |
+
from websockets.exceptions import ConnectionClosedError
|
25 |
import json
|
26 |
import stripe
|
27 |
import jwt
|
|
|
412 |
|
413 |
try:
|
414 |
while True:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
415 |
|
416 |
+
authinfo = await websocket.receive_json()
|
417 |
+
#print(authinfo)
|
418 |
+
authorization = authinfo["headers"]["Authorization"]
|
419 |
+
current_user = secure_decode(authorization.replace("Bearer ",""))["email"]
|
420 |
+
if current_user:
|
421 |
+
try:
|
422 |
+
email_exists = importcsv.db.accountrevisioncards.find_one({"email":current_user})
|
423 |
+
if email_exists: # Checks if email exists
|
424 |
+
user_revision_cards = list(importcsv.db.accountrevisioncards.find({"email": current_user}))[0]
|
425 |
+
del user_revision_cards["_id"],user_revision_cards["email"]
|
426 |
+
#return StreamingResponse(iter_df(user_revision_cards), media_type="application/json")
|
427 |
+
#return user_revision_cards
|
428 |
+
for revisioncard in user_revision_cards["revisioncards"]:
|
429 |
+
revisioncard.update({"revisionscheduleinterval":user_revision_cards["revisionscheduleinterval"],"sendtoemail":user_revision_cards["sendtoemail"]})
|
430 |
+
await websocket.send_json(json.dumps(revisioncard)) # sends the buffer as bytes
|
431 |
+
elif not email_exists:
|
432 |
+
await websocket.send_json(json.dumps({"message":"No revision cards"}))
|
433 |
+
#return {"message":"No revision cards"} # Send in shape of data
|
434 |
+
except Exception as ex:
|
435 |
+
return {f"error":f"{type(ex)},{str(ex)}"}
|
436 |
+
elif not current_user:
|
437 |
+
await websocket.send_json(json.dumps({"message":"No user."}))
|
438 |
+
except ConnectionClosedError as cex:
|
439 |
+
await websocket.send_json(json.dumps({"error":f"{type(cex)},{cex}"}))
|
440 |
|
441 |
|
442 |
|
requirements.txt
CHANGED
@@ -69,7 +69,7 @@ thinc==8.0.13
|
|
69 |
tornado==6.1
|
70 |
tqdm==4.62.3
|
71 |
traitlets==5.1.1
|
72 |
-
websockets
|
73 |
typer==0.4.0
|
74 |
typing_extensions==4.0.1
|
75 |
urllib3==1.26.7
|
|
|
69 |
tornado==6.1
|
70 |
tqdm==4.62.3
|
71 |
traitlets==5.1.1
|
72 |
+
websockets==11.0.3
|
73 |
typer==0.4.0
|
74 |
typing_extensions==4.0.1
|
75 |
urllib3==1.26.7
|