Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1132,21 +1132,22 @@ def create_gradio_interface(state=None):
|
|
1132 |
# In[21]:
|
1133 |
demo = create_gradio_interface()
|
1134 |
# Use Gradio's `server_app` to get an ASGI app for Blocks
|
1135 |
-
gradio_asgi_app = gr.routes.App.create_app(demo)
|
1136 |
|
1137 |
logging.debug(f"Gradio version: {gr.__version__}")
|
|
|
1138 |
|
1139 |
# Mount the Gradio ASGI app at "/gradio"
|
1140 |
app.mount("/gradio", gradio_asgi_app)
|
1141 |
-
|
1142 |
-
#
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
#
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
|
1151 |
# Redirect from the root endpoint to the Gradio app
|
1152 |
@app.get("/", response_class=RedirectResponse)
|
|
|
1132 |
# In[21]:
|
1133 |
demo = create_gradio_interface()
|
1134 |
# Use Gradio's `server_app` to get an ASGI app for Blocks
|
1135 |
+
gradio_asgi_app = gr.routes.App.create_app(demo, server_path="/gradio")
|
1136 |
|
1137 |
logging.debug(f"Gradio version: {gr.__version__}")
|
1138 |
+
logging.debug(f"FastAPI version: {fastapi.__version__}")
|
1139 |
|
1140 |
# Mount the Gradio ASGI app at "/gradio"
|
1141 |
app.mount("/gradio", gradio_asgi_app)
|
1142 |
+
|
1143 |
+
# Dynamically check for the Gradio asset directory
|
1144 |
+
gradio_assets_path = os.path.join(os.path.dirname(gr.__file__), "static")
|
1145 |
+
|
1146 |
+
if os.path.exists(gradio_assets_path):
|
1147 |
+
# If assets exist, mount them
|
1148 |
+
app.mount("/assets", StaticFiles(directory=gradio_assets_path), name="assets")
|
1149 |
+
else:
|
1150 |
+
logging.error(f"Gradio assets directory not found at: {gradio_assets_path}")
|
1151 |
|
1152 |
# Redirect from the root endpoint to the Gradio app
|
1153 |
@app.get("/", response_class=RedirectResponse)
|