Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -41,10 +41,17 @@ def list_roms():
|
|
| 41 |
if not os.path.exists(EXTRACTED_FOLDER):
|
| 42 |
print("ROM folder missing.")
|
| 43 |
return []
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
print("Found ROMs:", roms) # Debugging output
|
| 47 |
-
return roms
|
| 48 |
|
| 49 |
# Generate HTML content with links to the ROMs
|
| 50 |
def generate_html():
|
|
@@ -65,7 +72,7 @@ def generate_html():
|
|
| 65 |
if rom_files:
|
| 66 |
for rom_name in rom_files:
|
| 67 |
# Adjust for Gradio file serving
|
| 68 |
-
rom_url = f"/file/{
|
| 69 |
html_content += f'<li><a href="play.html?rom={rom_url}">{rom_name}</a></li>'
|
| 70 |
else:
|
| 71 |
html_content += "<li>No ROMs available</li>"
|
|
@@ -94,3 +101,4 @@ gradio_app()
|
|
| 94 |
|
| 95 |
|
| 96 |
|
|
|
|
|
|
| 41 |
if not os.path.exists(EXTRACTED_FOLDER):
|
| 42 |
print("ROM folder missing.")
|
| 43 |
return []
|
| 44 |
+
|
| 45 |
+
# Debugging output: List all files in the directory
|
| 46 |
+
print("Listing all files in extracted folder:")
|
| 47 |
+
for root, dirs, files in os.walk(EXTRACTED_FOLDER):
|
| 48 |
+
for file in files:
|
| 49 |
+
print(f"Found file: {file}")
|
| 50 |
+
|
| 51 |
+
# Look for .nes files in all directories
|
| 52 |
+
roms = [f for f in Path(EXTRACTED_FOLDER).rglob("*.nes")]
|
| 53 |
print("Found ROMs:", roms) # Debugging output
|
| 54 |
+
return [str(rom.relative_to(EXTRACTED_FOLDER)) for rom in roms]
|
| 55 |
|
| 56 |
# Generate HTML content with links to the ROMs
|
| 57 |
def generate_html():
|
|
|
|
| 72 |
if rom_files:
|
| 73 |
for rom_name in rom_files:
|
| 74 |
# Adjust for Gradio file serving
|
| 75 |
+
rom_url = f"/file/{rom_name}"
|
| 76 |
html_content += f'<li><a href="play.html?rom={rom_url}">{rom_name}</a></li>'
|
| 77 |
else:
|
| 78 |
html_content += "<li>No ROMs available</li>"
|
|
|
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
+
|