Skip to content

Drop in a screenshot and convert it to clean code (HTML/Tailwind/React/Vue)

Python

use platform api key if the access code is correct

Abi Raja8a242103fcc9
diff --git a/backend/main.py b/backend/main.py
index eb1b0f9d..117c58c1 100644
--- a/backend/main.py
+++ b/backend/main.py
@@ -81,7 +81,17 @@ async def stream_code(websocket: WebSocket):
# If neither is provided, we throw an error.
openai_api_key = None
if "accessCode" in params and params["accessCode"]:
- print("Using access code")
+ print("Access code - using platform API key")
+ if params["accessCode"] == "hi":
+ openai_api_key = os.environ.get("PLATFORM_OPENAI_API_KEY")
+ else:
+ await websocket.send_json(
+ {
+ "type": "error",
+ "value": "Invalid access code. Please try again.",
+ }
+ )
+ return
else:
if params["openAiApiKey"]:
openai_api_key = params["openAiApiKey"]