pszemraj commited on
Commit
fadbdc4
1 Parent(s): 0f6a513

✨ add colab checker

Browse files

Signed-off-by: peter szemraj <[email protected]>

Files changed (2) hide show
  1. app.py +2 -0
  2. utils.py +10 -0
app.py CHANGED
@@ -238,4 +238,6 @@ with gr.Blocks(theme=theme, analytics_enabled=False, css=_styles) as demo:
238
  demo.queue(max_size=10).launch(
239
  debug=True,
240
  server_port=DEFAULT_PORT,
 
 
241
  )
 
238
  demo.queue(max_size=10).launch(
239
  debug=True,
240
  server_port=DEFAULT_PORT,
241
+ show_api=False,
242
+ share=utils.is_google_colab(),
243
  )
utils.py CHANGED
@@ -4,6 +4,16 @@ from typing import List
4
  from settings import STATIC_PATH
5
 
6
 
 
 
 
 
 
 
 
 
 
 
7
  def get_file_as_string(file_name, path=STATIC_PATH) -> str:
8
  """Loads the content of a file given its name
9
  and returns all of its lines as a single string
 
4
  from settings import STATIC_PATH
5
 
6
 
7
+ def is_google_colab():
8
+ """Check if the environment is Google Colab."""
9
+ try:
10
+ from google.colab import drive
11
+
12
+ return True
13
+ except ImportError:
14
+ return False
15
+
16
+
17
  def get_file_as_string(file_name, path=STATIC_PATH) -> str:
18
  """Loads the content of a file given its name
19
  and returns all of its lines as a single string