File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change 6
6
from mesop .server .logging import log_startup
7
7
from mesop .server .server import configure_flask_app
8
8
from mesop .server .static_file_serving import configure_static_file_serving
9
+ from mesop .utils .colab_utils import is_running_in_colab
9
10
10
11
11
12
def colab_run ():
12
13
"""
13
- Typically only used for Colab/Jupyter notebooks, otherwise you'll use the CLI
14
- to execute a Mesop application.
14
+ When running in Colab environment, this will launch the web server.
15
+
16
+ Otherwise, this is a no-op.
15
17
"""
18
+ if not is_running_in_colab ():
19
+ print ("Not running Colab: `colab_run` is a no-op" )
20
+ return
16
21
flask_app = configure_flask_app ()
17
22
enable_debug_mode ()
18
23
configure_static_file_serving (
Original file line number Diff line number Diff line change
1
+ import builtins
2
+ import sys
3
+
4
+
5
+ def is_running_in_colab () -> bool :
6
+ return "google.colab" in sys .modules and hasattr (builtins , "get_ipython" )
You can’t perform that action at this time.
0 commit comments