SalexAI commited on
Commit
bfc7017
·
verified ·
1 Parent(s): be8d343

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -9
app.py CHANGED
@@ -217,17 +217,22 @@ def read_root():
217
  </html>
218
  """
219
 
220
- # Gradio Interface for displaying the stored data
 
 
 
 
 
221
  def show_data():
222
  return json.dumps(lists, indent=4) # Return the data as formatted JSON
223
 
224
- # Gradio app interface
225
- gr_interface = gr.Interface(fn=show_data, inputs=[], outputs="text")
226
 
227
- # Add the Gradio app to FastAPI
228
- app = gr.mount_gradio_app(app, gr_interface, path="/gradio")
229
 
230
- # FastAPI default root (e.g. for status or basic testing)
231
- @app.get("/gradio/data")
232
- async def get_data():
233
- return lists
 
217
  </html>
218
  """
219
 
220
+ # FastAPI endpoint to get data
221
+ @app.get("/gradio/data")
222
+ async def get_data():
223
+ return lists
224
+
225
+ # Define Gradio interface
226
  def show_data():
227
  return json.dumps(lists, indent=4) # Return the data as formatted JSON
228
 
229
+ # Create the Gradio interface
230
+ gradio_app = gr.Interface(fn=show_data, inputs=[], outputs="text")
231
 
232
+ # Mount the Gradio app to FastAPI
233
+ app = gr.mount_gradio_app(app, gradio_app, path="/gradio")
234
 
235
+ # Add this if you're running this script directly
236
+ if __name__ == "__main__":
237
+ import uvicorn
238
+ uvicorn.run(app, host="0.0.0.0", port=8000)