Decoo commited on
Commit
f3a5b42
·
1 Parent(s): 572b5e7

modified app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -9
app.py CHANGED
@@ -76,15 +76,27 @@ for key, folder in FOLDER_MAP.items():
76
  with open(index_path, 'w') as f:
77
  json.dump(files, f)
78
  print(f"Created {index_path} with {len(files)} files")
 
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
- # Read your original HTML
81
- html_path = "Viewer/viewer_v2.html"
82
- if os.path.exists(html_path):
83
- with open(html_path, "r", encoding="utf-8") as f:
84
- original_html = f.read()
85
- else:
86
- print(f"WARNING: {html_path} not found!")
87
- original_html = "<h1>Error: viewer_v2.html not found</h1>"
88
 
89
  # Create Gradio interface
90
  with gr.Blocks(title="Report Viewer", theme=gr.themes.Soft()) as demo:
@@ -140,5 +152,7 @@ with gr.Blocks(title="Report Viewer", theme=gr.themes.Soft()) as demo:
140
  if __name__ == "__main__":
141
  # Launch with file serving enabled
142
  demo.launch(
143
- allowed_paths=["Viewer"]
 
 
144
  )
 
76
  with open(index_path, 'w') as f:
77
  json.dump(files, f)
78
  print(f"Created {index_path} with {len(files)} files")
79
+ else:
80
+ print(f"WARNING: Folder {folder} does not exist")
81
+
82
+ # Read HTML file - prova diversi percorsi possibili
83
+ html_paths = ["Viewer/viewer_v2.html", "viewer_v2.html", "./viewer_v2.html"]
84
+ original_html = None
85
+
86
+ for html_path in html_paths:
87
+ if os.path.exists(html_path):
88
+ with open(html_path, "r", encoding="utf-8") as f:
89
+ original_html = f.read()
90
+ print(f"✅ Found HTML at: {html_path}")
91
+ break
92
 
93
+ if original_html is None:
94
+ print("❌ ERROR: viewer_v2.html not found in any expected location!")
95
+ print(f"Current directory: {os.getcwd()}")
96
+ print(f"Files in current directory: {os.listdir('.')}")
97
+ if os.path.exists('Viewer'):
98
+ print(f"Files in Viewer directory: {os.listdir('Viewer')}")
99
+ original_html = "<h1>Error: viewer_v2.html not found</h1><p>Please check the file structure.</p>"
 
100
 
101
  # Create Gradio interface
102
  with gr.Blocks(title="Report Viewer", theme=gr.themes.Soft()) as demo:
 
152
  if __name__ == "__main__":
153
  # Launch with file serving enabled
154
  demo.launch(
155
+ server_name="0.0.0.0", # Necessario per Hugging Face Spaces
156
+ server_port=7860, # Porta standard di Gradio
157
+ allowed_paths=[".", "Viewer", "Viewer/Data"] # Permetti accesso a più cartelle
158
  )