Spaces:
Build error
Build error
checking SPACE_HOST to add https to redirect
Browse files
main.py
CHANGED
|
@@ -103,7 +103,7 @@ def query_from_request(sql_input, definitions, request: gr.Request):
|
|
| 103 |
q.save()
|
| 104 |
query_id = q.id
|
| 105 |
alias = q.alias
|
| 106 |
-
hf_space_host = getenv("SPACE_HOST")
|
| 107 |
if hf_space_host:
|
| 108 |
iframe_src = f"https://{hf_space_host}/q?query_id={query_id}"
|
| 109 |
else:
|
|
@@ -170,9 +170,15 @@ def change_hf_host(request: gr.Request):
|
|
| 170 |
app = gr.mount_gradio_app(app, gradio_sql_interface, path="/sql")
|
| 171 |
|
| 172 |
@app.get("/")
|
| 173 |
-
def redirect_hack():
|
| 174 |
-
|
| 175 |
|
| 176 |
-
@app.get("/redirecting")
|
| 177 |
def redirect_to_example():
|
| 178 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
q.save()
|
| 104 |
query_id = q.id
|
| 105 |
alias = q.alias
|
| 106 |
+
hf_space_host = None #getenv("SPACE_HOST")
|
| 107 |
if hf_space_host:
|
| 108 |
iframe_src = f"https://{hf_space_host}/q?query_id={query_id}"
|
| 109 |
else:
|
|
|
|
| 170 |
app = gr.mount_gradio_app(app, gradio_sql_interface, path="/sql")
|
| 171 |
|
| 172 |
@app.get("/")
|
| 173 |
+
# def redirect_hack():
|
| 174 |
+
# return RedirectResponse("/redirecting")
|
| 175 |
|
| 176 |
+
# @app.get("/redirecting")
|
| 177 |
def redirect_to_example():
|
| 178 |
+
hf_space_host = getenv("SPACE_HOST")
|
| 179 |
+
if hf_space_host:
|
| 180 |
+
return RedirectResponse(f"https://{hf_space_host}/q?alias=example1")
|
| 181 |
+
else:
|
| 182 |
+
return RedirectResponse("/sql?alias=example1")
|
| 183 |
+
|
| 184 |
+
# return RedirectResponse("/sql?alias=example1")
|