phenixrhyder
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,65 +1,21 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
|
4 |
-
# --- THIS IS THE DEBUGGING VERSION ---
|
5 |
-
|
6 |
# Get the absolute path to the directory where this script is located
|
7 |
script_dir = os.path.dirname(os.path.abspath(__file__))
|
8 |
-
#
|
9 |
-
cwd = os.getcwd()
|
10 |
-
|
11 |
-
# Construct the full path to index.html
|
12 |
html_file_path = os.path.join(script_dir, 'index.html')
|
13 |
|
14 |
-
#
|
15 |
try:
|
16 |
with open(html_file_path, 'r', encoding='utf-8') as f:
|
17 |
html_content = f.read()
|
18 |
except FileNotFoundError:
|
19 |
-
|
20 |
-
|
21 |
-
# List files in the script's directory
|
22 |
-
try:
|
23 |
-
script_dir_files = os.listdir(script_dir)
|
24 |
-
script_dir_files_str = "<br>".join(script_dir_files)
|
25 |
-
except Exception as e:
|
26 |
-
script_dir_files_str = f"Could not list files: {e}"
|
27 |
-
|
28 |
-
# List files in the current working directory
|
29 |
-
try:
|
30 |
-
cwd_files = os.listdir(cwd)
|
31 |
-
cwd_files_str = "<br>".join(cwd_files)
|
32 |
-
except Exception as e:
|
33 |
-
cwd_files_str = f"Could not list files: {e}"
|
34 |
|
35 |
-
|
36 |
-
|
37 |
-
<div style="font-family: monospace; color: #d1d5db; background-color: #1f2937; padding: 2rem; border-radius: 1rem; border: 1px solid #374151;">
|
38 |
-
<h1 style="color: #ef4444; font-size: 1.5rem;">File Not Found Error</h1>
|
39 |
-
<p style="color: #9ca3af; margin-top: 1rem;">The server could not find 'index.html'.</p>
|
40 |
-
|
41 |
-
<h2 style="color: #f9fafb; margin-top: 2rem; border-bottom: 1px solid #374151; padding-bottom: 0.5rem;">Debugging Info:</h2>
|
42 |
-
|
43 |
-
<h3 style="color: #60a5fa; margin-top: 1.5rem;">Expected File Path:</h3>
|
44 |
-
<p>{html_file_path}</p>
|
45 |
-
|
46 |
-
<h3 style="color: #60a5fa; margin-top: 1.5rem;">Files found in the script's directory ({script_dir}):</h3>
|
47 |
-
<div style="background-color: #111827; padding: 1rem; border-radius: 0.5rem; margin-top: 0.5rem;">
|
48 |
-
{script_dir_files_str}
|
49 |
-
</div>
|
50 |
-
|
51 |
-
<h3 style="color: #60a5fa; margin-top: 1.5rem;">Files found in the current working directory ({cwd}):</h3>
|
52 |
-
<div style="background-color: #111827; padding: 1rem; border-radius: 0.5rem; margin-top: 0.5rem;">
|
53 |
-
{cwd_files_str}
|
54 |
-
</div>
|
55 |
-
</div>
|
56 |
-
"""
|
57 |
-
|
58 |
-
# Create a Gradio Blocks interface
|
59 |
-
with gr.Blocks(title="Frame Studio Debug", css="body {{background-color: #111827;}}") as demo:
|
60 |
-
# Use gr.HTML() to render your full HTML file or the debug info.
|
61 |
gr.HTML(html_content)
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
|
|
|
|
|
4 |
# Get the absolute path to the directory where this script is located
|
5 |
script_dir = os.path.dirname(os.path.abspath(__file__))
|
6 |
+
# Join that directory path with the filename to get the full path to index.html
|
|
|
|
|
|
|
7 |
html_file_path = os.path.join(script_dir, 'index.html')
|
8 |
|
9 |
+
# Read the entire content of the index.html file using the full path
|
10 |
try:
|
11 |
with open(html_file_path, 'r', encoding='utf-8') as f:
|
12 |
html_content = f.read()
|
13 |
except FileNotFoundError:
|
14 |
+
html_content = "<h1>Error: index.html not found.</h1>"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
+
# Create and launch the Gradio interface
|
17 |
+
with gr.Blocks(title="Frame Studio") as demo:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
gr.HTML(html_content)
|
19 |
|
20 |
+
demo.launch()
|
21 |
+
|
|