Spaces:
Sleeping
Sleeping
wip
Browse files
app.py
CHANGED
|
@@ -1432,8 +1432,6 @@ def build_app() -> gr.Blocks:
|
|
| 1432 |
|
| 1433 |
def main() -> None:
|
| 1434 |
"""Launch the Visual Novel Gradio app."""
|
| 1435 |
-
from fastapi import FastAPI
|
| 1436 |
-
|
| 1437 |
# Get absolute paths for static directories
|
| 1438 |
script_dir = os.path.dirname(os.path.abspath(__file__))
|
| 1439 |
assets_dir = os.path.join(script_dir, "assets")
|
|
@@ -1452,30 +1450,30 @@ def main() -> None:
|
|
| 1452 |
files = os.listdir(subdir_path)
|
| 1453 |
logger.info(f" {subdir}/ files: {files[:5]}") # Show first 5 files
|
| 1454 |
|
| 1455 |
-
# Create custom FastAPI app and mount static files FIRST
|
| 1456 |
-
logger.info("Creating FastAPI app...")
|
| 1457 |
-
app = FastAPI()
|
| 1458 |
-
|
| 1459 |
-
logger.info(f"Mounting /assets -> {assets_dir}")
|
| 1460 |
-
app.mount("/assets", StaticFiles(directory=assets_dir, html=False), name="assets")
|
| 1461 |
-
logger.info("Static files mounted on custom FastAPI app")
|
| 1462 |
-
|
| 1463 |
# Build Gradio app
|
| 1464 |
logger.info("Building Gradio app...")
|
| 1465 |
demo = build_app()
|
| 1466 |
|
| 1467 |
-
#
|
| 1468 |
-
logger.info("
|
| 1469 |
-
|
| 1470 |
-
|
| 1471 |
-
|
| 1472 |
-
|
| 1473 |
-
|
| 1474 |
-
|
| 1475 |
-
|
| 1476 |
-
|
| 1477 |
-
|
| 1478 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1479 |
)
|
| 1480 |
|
| 1481 |
|
|
|
|
| 1432 |
|
| 1433 |
def main() -> None:
|
| 1434 |
"""Launch the Visual Novel Gradio app."""
|
|
|
|
|
|
|
| 1435 |
# Get absolute paths for static directories
|
| 1436 |
script_dir = os.path.dirname(os.path.abspath(__file__))
|
| 1437 |
assets_dir = os.path.join(script_dir, "assets")
|
|
|
|
| 1450 |
files = os.listdir(subdir_path)
|
| 1451 |
logger.info(f" {subdir}/ files: {files[:5]}") # Show first 5 files
|
| 1452 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1453 |
# Build Gradio app
|
| 1454 |
logger.info("Building Gradio app...")
|
| 1455 |
demo = build_app()
|
| 1456 |
|
| 1457 |
+
# Enable queue to create the FastAPI app
|
| 1458 |
+
logger.info("Enabling queue...")
|
| 1459 |
+
demo.queue()
|
| 1460 |
+
|
| 1461 |
+
# Mount static files on Gradio's app BEFORE launch
|
| 1462 |
+
logger.info(f"Mounting /assets -> {assets_dir}")
|
| 1463 |
+
try:
|
| 1464 |
+
# Mount at the beginning of the routes list
|
| 1465 |
+
demo.app.mount("/assets", StaticFiles(directory=assets_dir, html=False), name="assets")
|
| 1466 |
+
logger.info("Static files mounted successfully")
|
| 1467 |
+
except Exception as e:
|
| 1468 |
+
logger.error(f"Failed to mount static files: {e}")
|
| 1469 |
+
|
| 1470 |
+
# Launch with SSR disabled
|
| 1471 |
+
logger.info("Launching app...")
|
| 1472 |
+
demo.launch(
|
| 1473 |
+
server_name="0.0.0.0",
|
| 1474 |
+
server_port=7860,
|
| 1475 |
+
ssr_mode=False,
|
| 1476 |
+
show_error=True,
|
| 1477 |
)
|
| 1478 |
|
| 1479 |
|