qqwjq1981 commited on
Commit
edadb68
·
verified ·
1 Parent(s): c29d645

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
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
- # # Dynamically check for the Gradio asset directory
1143
- # gradio_assets_path = os.path.join(os.path.dirname(gr.__file__), "static")
1144
-
1145
- # if os.path.exists(gradio_assets_path):
1146
- # # If assets exist, mount them
1147
- # app.mount("/assets", StaticFiles(directory=gradio_assets_path), name="assets")
1148
- # else:
1149
- # logging.error(f"Gradio assets directory not found at: {gradio_assets_path}")
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)