Browse Source

Update demo command to open demo.reflex.run (#2059)

Nikhil Rao 1 năm trước cách đây
mục cha
commit
bb77d14fbc
2 tập tin đã thay đổi với 18 bổ sung15 xóa
  1. 17 12
      reflex/reflex.py
  2. 1 3
      reflex/utils/hosting.py

+ 17 - 12
reflex/reflex.py

@@ -7,6 +7,7 @@ import os
 import shutil
 import tempfile
 import time
+import webbrowser
 from datetime import datetime
 from pathlib import Path
 from typing import List, Optional
@@ -714,18 +715,22 @@ def demo(
     backend_port: str = typer.Option("8001", help="Specify a different backend port."),
 ):
     """Run the demo app."""
-    with tempfile.TemporaryDirectory() as tmp_dir:
-        os.chdir(tmp_dir)
-        _init(
-            name="reflex_demo",
-            template=constants.Templates.Kind.DEMO,
-            loglevel=constants.LogLevel.ERROR,
-        )
-        _run(
-            frontend_port=frontend_port,
-            backend_port=backend_port,
-            loglevel=constants.LogLevel.ERROR,
-        )
+    # Open the demo app in a terminal.
+    webbrowser.open("https://demo.reflex.run")
+
+    # Later: open the demo app locally.
+    # with tempfile.TemporaryDirectory() as tmp_dir:
+    #     os.chdir(tmp_dir)
+    #     _init(
+    #         name="reflex_demo",
+    #         template=constants.Templates.Kind.DEMO,
+    #         loglevel=constants.LogLevel.DEBUG,
+    #     )
+    #     _run(
+    #         frontend_port=frontend_port,
+    #         backend_port=backend_port,
+    #         loglevel=constants.LogLevel.DEBUG,
+    #     )
 
 
 deployments_cli = typer.Typer()

+ 1 - 3
reflex/utils/hosting.py

@@ -878,9 +878,7 @@ def check_requirements_for_non_reflex_packages() -> bool:
     return False
 
 
-def authenticate_on_browser(
-    invitation_code: str,
-) -> str:
+def authenticate_on_browser(invitation_code: str) -> str:
     """Open the browser to authenticate the user.
 
     Args: