Add redirect logic

This commit is contained in:
Elijah 2024-11-15 19:27:04 +00:00
parent 128d6d103c
commit 37b19d286a
2 changed files with 14 additions and 4 deletions

View File

@ -1493,6 +1493,7 @@ def fetch_and_prompt_with_remote_templates(
if not show_prompt and (template not in available_templates):
console.error(f"{template!r} is not a valid template name.")
redir.open_browser(constants.Templates.REFLEX_TEMPLATES_URL)
template = (
prompt_for_remote_template_selection(available_templates)
if available_templates

View File

@ -10,6 +10,18 @@ from .. import constants
from . import console
def open_browser(target_url: str) -> None:
"""Open a browser window to target_url.
Args:
target_url: The URL to open in the browser.
"""
if not webbrowser.open(target_url):
console.warn(
f"Unable to automatically open the browser. Please navigate to {target_url} in your browser."
)
def open_browser_and_wait(
target_url: str, poll_url: str, interval: int = 2
) -> httpx.Response:
@ -23,10 +35,7 @@ def open_browser_and_wait(
Returns:
The response from the poll_url.
"""
if not webbrowser.open(target_url):
console.warn(
f"Unable to automatically open the browser. Please navigate to {target_url} in your browser."
)
open_browser(target_url)
console.info("[b]Complete the workflow in the browser to continue.[/b]")
while True:
try: