From aea45df9532159dae8f88d19e5341f349b23dfab Mon Sep 17 00:00:00 2001 From: Rahul Bagai Date: Mon, 17 Jul 2023 21:20:22 +0000 Subject: [PATCH 1/4] Updates made to facilitate GitHub Codespaces. --- .devcontainer/devcontainer.json | 7 +++++++ reflex/constants.py | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000000..fb07b9c2c4 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,7 @@ +{ + "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", + "features": { + "ghcr.io/devcontainers/features/node:1": {} + }, + "postCreateCommand": "/bin/bash -c '/usr/local/bin/pip install poetry'" +} \ No newline at end of file diff --git a/reflex/constants.py b/reflex/constants.py index 3a39ff3f0c..acf0679e6e 100644 --- a/reflex/constants.py +++ b/reflex/constants.py @@ -105,7 +105,9 @@ def get_value(key: str, default: Any = None, type_: Type = str) -> Type: # The backend default port. BACKEND_PORT = get_value("BACKEND_PORT", "8000") # The backend api url. -API_URL = get_value("API_URL", "http://localhost:8000") +CODESPACE_NAME=os.getenv("CODESPACE_NAME") +GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN=os.getenv("GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN") +API_URL = get_value("API_URL", f"https://{CODESPACE_NAME}-8000.{GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}") # The deploy url DEPLOY_URL = get_value("DEPLOY_URL") # bun root location From 8f1b1fd78dca92344079f34caeedb7ffd7f861d7 Mon Sep 17 00:00:00 2001 From: Rahul Bagai Date: Mon, 17 Jul 2023 21:33:17 +0000 Subject: [PATCH 2/4] Enhancing the generation of the GitHub Codespaces API URL by introducing a condition. --- reflex/constants.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/reflex/constants.py b/reflex/constants.py index acf0679e6e..cdee858dc0 100644 --- a/reflex/constants.py +++ b/reflex/constants.py @@ -107,7 +107,10 @@ def get_value(key: str, default: Any = None, type_: Type = str) -> Type: # The backend api url. CODESPACE_NAME=os.getenv("CODESPACE_NAME") GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN=os.getenv("GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN") -API_URL = get_value("API_URL", f"https://{CODESPACE_NAME}-8000.{GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}") +if CODESPACE_NAME: + API_URL = get_value("API_URL", f"https://{CODESPACE_NAME}-8000.{GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}") +else: + API_URL = get_value("API_URL", "http://localhost:8000") # The deploy url DEPLOY_URL = get_value("DEPLOY_URL") # bun root location From 2c52a12aa891e3accfe8b5315670b71017ebdb72 Mon Sep 17 00:00:00 2001 From: Rahul Bagai Date: Mon, 17 Jul 2023 21:53:31 +0000 Subject: [PATCH 3/4] reformatting constants.py --- reflex/constants.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/reflex/constants.py b/reflex/constants.py index cdee858dc0..b52cdbb514 100644 --- a/reflex/constants.py +++ b/reflex/constants.py @@ -105,10 +105,15 @@ def get_value(key: str, default: Any = None, type_: Type = str) -> Type: # The backend default port. BACKEND_PORT = get_value("BACKEND_PORT", "8000") # The backend api url. -CODESPACE_NAME=os.getenv("CODESPACE_NAME") -GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN=os.getenv("GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN") +CODESPACE_NAME = os.getenv("CODESPACE_NAME") +GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN = os.getenv( + "GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN" +) if CODESPACE_NAME: - API_URL = get_value("API_URL", f"https://{CODESPACE_NAME}-8000.{GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}") + API_URL = get_value( + "API_URL", + f"https://{CODESPACE_NAME}-8000.{GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN}", + ) else: API_URL = get_value("API_URL", "http://localhost:8000") # The deploy url From 2e482f467bb07bdaf30030bf02af946f9079a0b8 Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Mon, 31 Jul 2023 13:17:14 -0700 Subject: [PATCH 4/4] devcontainer.json: use bookworm variant --- .devcontainer/devcontainer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index fb07b9c2c4..2ef0284702 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,7 +1,7 @@ { - "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye", + "image": "mcr.microsoft.com/devcontainers/python:1-3.11-bookworm", "features": { "ghcr.io/devcontainers/features/node:1": {} }, "postCreateCommand": "/bin/bash -c '/usr/local/bin/pip install poetry'" -} \ No newline at end of file +}