Spaces:
No application file
No application file
Update app.py
Browse files
app.py
CHANGED
|
@@ -977,19 +977,11 @@ def create_interface():
|
|
| 977 |
def open_tree(html_file):
|
| 978 |
if html_file and os.path.exists(html_file):
|
| 979 |
try:
|
| 980 |
-
|
| 981 |
-
|
| 982 |
-
|
| 983 |
-
if space_url:
|
| 984 |
-
# Construct a URL to the file (relative path from the Space root)
|
| 985 |
-
file_path = os.path.relpath(html_file, os.getcwd())
|
| 986 |
-
file_url = f"{space_url}/file={file_path}"
|
| 987 |
-
return gr.update(value=f"<script>window.open('{file_url}', '_blank');</script>")
|
| 988 |
-
else:
|
| 989 |
-
# Fallback for local testing or if space_url fails
|
| 990 |
-
return gr.update(value=f"<p>Please download the file and open it in your browser: <a href='/file={html_file}' download>Download</a></p>")
|
| 991 |
except Exception as e:
|
| 992 |
-
return gr.update(value=f"<p>Error opening tree: {str(e)}. Please download and open
|
| 993 |
return gr.update(value="<p>No tree file available. Run analysis to generate one.</p>")
|
| 994 |
|
| 995 |
# Connect events
|
|
|
|
| 977 |
def open_tree(html_file):
|
| 978 |
if html_file and os.path.exists(html_file):
|
| 979 |
try:
|
| 980 |
+
# Use Gradio's file serving by providing the file path directly
|
| 981 |
+
file_url = f"/file={html_file}"
|
| 982 |
+
return gr.update(value=f"<script>window.open('{file_url}', '_blank');</script>")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 983 |
except Exception as e:
|
| 984 |
+
return gr.update(value=f"<p>Error opening tree: {str(e)}. Please download the file and open it manually: <a href='/file={html_file}' download>Download</a></p>")
|
| 985 |
return gr.update(value="<p>No tree file available. Run analysis to generate one.</p>")
|
| 986 |
|
| 987 |
# Connect events
|