Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)
Python
return failure reason to front-end
Abi Rajaf0101036a0d9
diff --git a/backend/access_token.py b/backend/access_token.pyindex e61ef12a..35fa657d 100644--- a/backend/access_token.py+++ b/backend/access_token.py@@ -18,10 +18,4 @@ async def validate_access_token(access_code: str):response = await client.post(url, content=data, headers=headers)response_data = response.json()-- if response_data["success"]:- print("Access token is valid.")- return True- else:- print(f"Access token validation failed: {response_data['failure_reason']}")- return False+ return response_datadiff --git a/backend/main.py b/backend/main.pyindex bd38807a..cb8242a9 100644--- a/backend/main.py+++ b/backend/main.py@@ -97,13 +97,14 @@ async def stream_code(websocket: WebSocket):openai_api_key = Noneif "accessCode" in params and params["accessCode"]:print("Access code - using platform API key")- if await validate_access_token(params["accessCode"]):+ res = await validate_access_token(params["accessCode"])+ if res["success"]:openai_api_key = os.environ.get("PLATFORM_OPENAI_API_KEY")else:await websocket.send_json({"type": "error",- "value": "Invalid access code or you're out of credits. Please try again.",+ "value": res["failure_reason"],})return