Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -58,6 +58,7 @@ import fastapi
|
|
| 58 |
from fastapi import FastAPI, Request, HTTPException
|
| 59 |
from fastapi.responses import HTMLResponse, JSONResponse, RedirectResponse
|
| 60 |
from fastapi.staticfiles import StaticFiles
|
|
|
|
| 61 |
|
| 62 |
import nest_asyncio
|
| 63 |
from twilio.twiml.messaging_response import MessagingResponse
|
|
@@ -1140,15 +1141,22 @@ logging.debug(f"FastAPI version: {fastapi.__version__}")
|
|
| 1140 |
|
| 1141 |
# Mount the Gradio ASGI app at "/gradio"
|
| 1142 |
app.mount("/", gradio_asgi_app)
|
| 1143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1144 |
# Dynamically check for the Gradio asset directory
|
| 1145 |
-
gradio_assets_path = os.path.join(os.path.dirname(gr.__file__), "static")
|
| 1146 |
|
| 1147 |
-
if os.path.exists(gradio_assets_path):
|
| 1148 |
-
|
| 1149 |
-
|
| 1150 |
-
else:
|
| 1151 |
-
|
| 1152 |
|
| 1153 |
# # Redirect from the root endpoint to the Gradio app
|
| 1154 |
# @app.get("/", response_class=RedirectResponse)
|
|
|
|
| 58 |
from fastapi import FastAPI, Request, HTTPException
|
| 59 |
from fastapi.responses import HTMLResponse, JSONResponse, RedirectResponse
|
| 60 |
from fastapi.staticfiles import StaticFiles
|
| 61 |
+
from pathlib import Path
|
| 62 |
|
| 63 |
import nest_asyncio
|
| 64 |
from twilio.twiml.messaging_response import MessagingResponse
|
|
|
|
| 1141 |
|
| 1142 |
# Mount the Gradio ASGI app at "/gradio"
|
| 1143 |
app.mount("/", gradio_asgi_app)
|
| 1144 |
+
|
| 1145 |
+
# create a static directory to store the static files
|
| 1146 |
+
static_dir = Path('./static')
|
| 1147 |
+
static_dir.mkdir(parents=True, exist_ok=True)
|
| 1148 |
+
|
| 1149 |
+
# mount FastAPI StaticFiles server
|
| 1150 |
+
app.mount("/static", StaticFiles(directory=static_dir), name="static")
|
| 1151 |
+
|
| 1152 |
# Dynamically check for the Gradio asset directory
|
| 1153 |
+
# gradio_assets_path = os.path.join(os.path.dirname(gr.__file__), "static")
|
| 1154 |
|
| 1155 |
+
# if os.path.exists(gradio_assets_path):
|
| 1156 |
+
# # If assets exist, mount them
|
| 1157 |
+
# app.mount("/assets", StaticFiles(directory=gradio_assets_path), name="assets")
|
| 1158 |
+
# else:
|
| 1159 |
+
# logging.error(f"Gradio assets directory not found at: {gradio_assets_path}")
|
| 1160 |
|
| 1161 |
# # Redirect from the root endpoint to the Gradio app
|
| 1162 |
# @app.get("/", response_class=RedirectResponse)
|