lhoestq HF staff commited on
Commit
9d9f5bf
·
1 Parent(s): 16cc948

use host url

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -21,7 +21,9 @@ NUM_USER_DATASETS = 10
21
  SESSIONS_DIR = "s"
22
  SESSION_DIR_SPACES_SYMLINK = os.path.join("/data", SESSIONS_DIR)
23
  SPACE_ID = os.getenv("SPACE_ID")
24
- URL = f"https://huggingface.co/spaces/{SPACE_ID}" if SPACE_ID else "http://127.0.0.1:7870"
 
 
25
  css = """
26
  .transparent-dropdown, .transparent-dropdown .container .wrap, .transparent-accordion {
27
  background: var(--body-background-fill);
@@ -130,10 +132,10 @@ with gr.Blocks(css=css) as demo:
130
  split_dropdown: gr.Dropdown(**splits),
131
  session_state: session,
132
  dataframe: gr.DataFrame(**input_dataframe),
133
- share_link_textbox: f"{URL}?{SESSIONS_DIR}={session}",
134
  use_locally_markdown: (
135
- f"""In DuckDB:\n\n```sql\nATTACH '{URL}/gradio_api/file={SESSIONS_DIR}/{session}.duckdb AS db';\nUSE db;\nSELECT * FROM edited_dataset LIMIT 5;\n```\n\n"""
136
- f"""In Python:\n\n```python\nimport duckdb\n\nduckdb.sql("ATTACH '{URL}/gradio_api/file={SESSIONS_DIR}/{session}.duckdb' AS db")\nduckdb.sql("USE db")\ndf = duckdb.sql("SELECT * FROM edited_dataset LIMIT 5").df()\n```"""
137
  )
138
  }
139
 
 
21
  SESSIONS_DIR = "s"
22
  SESSION_DIR_SPACES_SYMLINK = os.path.join("/data", SESSIONS_DIR)
23
  SPACE_ID = os.getenv("SPACE_ID")
24
+ SPACE_HOST = os.getenv("SPACE_HOST")
25
+ APP_URL = f"https://huggingface.co/spaces/{SPACE_ID}" if SPACE_ID else "http://127.0.0.1:7870"
26
+ HOST_URL = f"https://{SPACE_HOST}" if SPACE_HOST else "http://127.0.0.1:7870"
27
  css = """
28
  .transparent-dropdown, .transparent-dropdown .container .wrap, .transparent-accordion {
29
  background: var(--body-background-fill);
 
132
  split_dropdown: gr.Dropdown(**splits),
133
  session_state: session,
134
  dataframe: gr.DataFrame(**input_dataframe),
135
+ share_link_textbox: f"{APP_URL}?{SESSIONS_DIR}={session}",
136
  use_locally_markdown: (
137
+ f"""In DuckDB:\n\n```sql\nATTACH '{HOST_URL}/gradio_api/file={SESSIONS_DIR}/{session}.duckdb AS db';\nUSE db;\nSELECT * FROM edited_dataset LIMIT 5;\n```\n\n"""
138
+ f"""In Python:\n\n```python\nimport duckdb\n\nduckdb.sql("ATTACH '{HOST_URL}/gradio_api/file={SESSIONS_DIR}/{session}.duckdb' AS db")\nduckdb.sql("USE db")\ndf = duckdb.sql("SELECT * FROM edited_dataset LIMIT 5").df()\n```"""
139
  )
140
  }
141